Reputation: 1929
This is a very simple question.
Some dates and timestamps are generated in my database.
How is this mdate build up so I can see what date and time is stored?
1st 1259575339
2nd 1261296844
I couldn't find a converter for this.
I have read that it's the the amount of seconds since 01-01-1970, is this correct?
Upvotes: 1
Views: 120
Reputation: 401002
Yes, it's the number of seconds since 1970-01-01 (see Unix Time on wikipedia, for more info).
In PHP, you have the date()
function to convert timestamps to dates as strings ; for example, this portion of code :
echo date('Y-m-d H:i:s', 1259575339) . '<br />';
echo date('Y-m-d H:i:s', 1261296844) . '<br />';
Will get you, in a browser :
2009-11-30 11:02:19
2009-12-20 09:14:04
In MySQL (if that's your DB engine), you can use the FROM_UNIXTIME function to convert those to dates :
mysql> select FROM_UNIXTIME(1259575339);
+---------------------------+
| FROM_UNIXTIME(1259575339) |
+---------------------------+
| 2009-11-30 11:02:19 |
+---------------------------+
1 row in set (0,07 sec)
mysql> select FROM_UNIXTIME(1261296844);
+---------------------------+
| FROM_UNIXTIME(1261296844) |
+---------------------------+
| 2009-12-20 09:14:04 |
+---------------------------+
1 row in set (0,00 sec)
Upvotes: 8