UREKA!

February 2, 2009 chrisyakimov

Thanks to this post: http://drupal.org/node/213714

I have discovered that migrating time information will be a breeze. In a nutshell:

MySQL timestamp is of the format yyyy-mm-dd hh:mm:ss

MySQL unix_timestamp() is of the form: xxxxxxxxxx where x is an integer (there are 10… currently). I believe this is a reference to the amount of seconds from the epoch time, which is some time in 1970. Drupal likes to store time in this format.

Converting from one to the other is as simple as these two rules (and functions – all in MySQL).

  1. unix_timestamp(MySQL timestamp) = xxxxxxxxxx
  2. from_unixtime(unix_timestamp()) = yyyy-mm-dd hh:mm:ss

If you have a date in the format of 2009-01-21 11:39:14 and you need that to be a 10 digit integer, just update the MySQL database with unix_timestamp(‘2009-01-02 11:39:14′). And if you have a 10 digit integer representing time, and you need a regular timestamp, wrap it in the function, from_unixtime(), like this: from_unixtime(‘1232566754′)

Entry Filed under: Uncategorized

Leave a Comment

Required

Required, hidden



Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to comments via RSS Feed

Pages

Categories

Calendar

February 2009
M T W T F S S
« Jan    
 1
2345678
9101112131415
16171819202122
232425262728  

Most Recent Posts