I use Angular 15.0 and ASP.NET Core 5 and SQL Server for my project. I install Jalali-moment in my SPA project to record and get Shamsi dates. When I record the date in Jalali format (e.g. 1401-10-10) of course, the time also is attached to the date, it is converted to Gregorian date and stored in the database.
Now when I retrieve the same date from the database it shows the previous day (e.g. 1401-10-09), Of course not always? I uses Jalali pipe to show retrieved date as Shamsi format.
The Jalali pipe I used:
import * as moment from 'jalali-moment';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'jalali'
})
export class JalaliPipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value === null || value === undefined) {
return '';
}
const MomentDate = moment(value, 'YYYY/MM/DD');
return MomentDate.locale('fa').format('YYYY/M/D');
}
}
I know There is a time difference, but Jalali-moment package should have solved this difference problem. However I have this problem and how to solve it? best regards