DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

DateTime To Double And Vice Versa

05.28.2007
| 5264 views |
  • submit to reddit
        
 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));
 }