I would like to know if there is any method to update/change system date & time using datepicker & timepicker? I can't find any sample code on it for reference. Please advise. Thanks.
updated:
DateTimeSettings is included in Windows IoT Extension SDK 16299.The method SetSystemDateTime is used to set the system date and time.Please refer to below codes.
//Change Date by DatePicker
private void DatePickerChangeSetting_DateChanged(object sender, DatePickerValueChangedEventArgs e)
{
DateTimeSettings.SetSystemDateTime(e.NewDate.UtcDateTime);
}
//Change Time by TimePicker
private void tpChangeSetting_TimeChanged(object sender, TimePickerValueChangedEventArgs e)
{
var currentDate = DateTime.Now.ToUniversalTime();
var newDateTime = new DateTime(currentDate.Year,
currentDate.Month,
currentDate.Day,
e.NewTime.Hours,
e.NewTime.Minutes,
e.NewTime.Seconds);
DateTimeSettings.SetSystemDateTime(newDateTime);
}
@Naikrovek, in the document linked, it is not error about the parameter DateTime/DateTimeOffset.In essence, the two can be transformed into each other.Please see Converting between DateTime and DateTimeOffsetc.In addition, the issue you mentioned about displaying the updated time on 16299 has been fixed, IoTCoreDefaultApp changed to with call NativeTimeMethods.GetLocalTime method.
In addition,i posted my reference setting and appxmanifest capability setting,you can install Windows IoT Extension for the UWP from here(download the windows 10 sdk and then install).