Re: String datetime to DateTime

From: Date: Thu, 20 Jun 2002 01:39:36 +0000
Subject: Re: String datetime to DateTime
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-19892@lists.php.net to get a copy of this message
DateTime formats are closer to what you have. strtotime() will give you an unsigned integer(ususally long/32bit) for the number of seconds since the unix epoch. Automagically from what you have to mySQL DateTime...nope...not that I can think of or find. If you have the Unix timestamp in ulong format, you can use date() to put it in the correct format. Obvious workaround... MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. $str = "12/Jun/2002:01:02:26 -0600"; $newstr = sscanf($str,"%d/%s/%d:%d:%d:%d $s",$day,$mon,$year,$hour,$min,$sec,$offset); $newdatestr = <rebuild it here> I never noticed that it didn't store the GMT offset before. heh. 'Luck -Mike ----- Original Message ----- From: "Glenn Holden" <glenn@nilenet.com> To: <php-db@lists.php.net> Sent: Wednesday, June 19, 2002 3:58 PM Subject: [PHP-DB] String datetime to DateTime > Hello All! > > I have a unix time stamp in string format like this: > > 12/Jun/2002:01:02:26 -0600 > > I am trying to turn that back into a mySQL DateTime value. I've > experimented with strtotime with no luck. I'm not really sure if that's > what it's for. > > I can, of course, parse the string manually to build a datetime that MySQL > will accept, but isn't there a function that handles this? > > How do -you- do this? > > Thanks! > -Glenn > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#19892) next »