I have a DateTime field in popup modal as below that is supposed to only show the time part:
HTML:
<div class='input-group date'>
<input class="form-control" type="datetime" #RequiredByDate name="RequiredByDate" [value]="formatDate(hitchRequest.requiredByDate, 'LT')" required>
<span class="input-group-addon">
<span class="fa fa-clock-o"></span>
</span>
</div>
TS:
formatDate(date: any, format: string): string {
if (!date) {
return '';
}
return moment(date).format(format);
}
onShown(): void {
$(this.requiredByDate.nativeElement).datetimepicker({
locale: abp.localization.currentLanguage.name,
format: 'LT',
});
}
When I set the DateTime and hit the save button the momentjs truly converts it to UTC time and send it to the server and eventually it is saved in DB in UTC time. My question is about when reading the data back from the server to the field. I assumed that the moment.js would reconvert it back to the local timezone like what it does when setting its value which seems it is not the case!
Any input is much appreciated :)