Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert ticks to unix timestamp

I m getting start time 634942626000000000 and end time 634942638000000000. How can I convert it to a Unix timestamp? I want to display formatted date/time in PHP?

like image 811
Ricky Watson Avatar asked Jan 20 '13 18:01

Ricky Watson


1 Answers

C# ticks is a number of ticks since midnight 0001-01-01 00:00:00 (every tick is 1/10000000 of second) and UNIX timestamp is number of seconds since beginning of the UNIX epoch (1970-01-01 01:00:00), so desired result is $seconds = 634942626000000000/10000000 - $number_of_seconds, where $number_of_seconds is seconds between 0001-00-01 00:00:00 and 1970-01-01 01:00:00. So, all you need now is to determine what $number_of_seconds is equals.

Update: this is how to do it in C# : How to convert a Unix timestamp to DateTime and vice versa?

Update 2 Using this simple script http://hastebin.com/lefiyiheju.mel determined that $number_of_seconds is 62136892800, but I don't know if it is much accurate

like image 152
Timur Avatar answered Sep 20 '22 10:09

Timur