0

uuhm..

I have another problem. I need to convert a TimePicker (Windows Phone 7) Value to a unix timestamp..

How is this possible?

Thanks!

fwartner
  • 13
  • 1
  • 6

1 Answers1

2

This should work:

DateTime selectedTime = ((DateTime) TimePicker.Value)

public static double ConvertToUnix (DateTime selDate)
{
    var unixStart = new DateTime (1970, 1, 1).ToLocalTime();
    return (selDate - unixStart).TotalSeconds;
}
Conner
  • 30,144
  • 8
  • 52
  • 73
Osiris
  • 4,195
  • 2
  • 22
  • 52
  • it works, but i am not sure what does happen to leap seconds, they are not included in unix-time, but they are included in usual time, isnt it so? – Erdinc Ay Sep 04 '15 at 16:13