Over a million developers have joined DZone.

DateTime To Double And Vice Versa

DZone's Guide to

DateTime To Double And Vice Versa

Free Resource

 public static double ToDouble(DateTime what)
  return BitConverter.ToDouble(BitConverter.GetBytes(what.Ticks), 0);

 public static DateTime ToDateTime(double what)
  return new DateTime(BitConverter.ToInt64(BitConverter.GetBytes(what), 0));

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}