is there any way to convert datetime to microsoft timestamp in flutter?

Try this:

final startOfTime = DateTime(1899, 12, 30);
double microsoftTimeStamp(DateTime date) {
  final diff = date.difference(startOfTime);
  return diff.inDays + ((diff - Duration(days: diff.inDays)).inSeconds / 86400);
}

Edit: the microsoft timestamp actually considers 1900-02-29 as a real date so using 1899-12-30 gives the correct result as long as you don’t need dates before 1900-03-01

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top