Hmm...odd. I guess their %s (yes that was a typo) looks for a space as a delimiter and not the specified next one.
Easiest workarounds off the cuff... 1) sscanf() to get the bulk of the data out, then regex out the %s string. 2) eregi_replace() Jun with the numeric 3) Dump it as numeric instead of a string month name 4) eregi_replace() the /'s with spaces then sscanf() it. 'Luck -Mike ----- Original Message ----- From: "Glenn Holden" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 20, 2002 8:48 AM Subject: Re: [PHP-DB] String datetime to DateTime > Thanks for the help, Mike. > Trouble with sscanf... > > Incidentally I changed the $s in the format string to %s, I think that was a > typo. :-) > > $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); > > The trouble I'm having is with the first %s. It doesn't see the next > delimiter so it puts the remaining text up to the next space into the $mon > string. > result: > $day = 12 > $mon = Jun/2002:01:02:26 > other variables are empty > > Looking at php help online, there was a spanish user comment that seemed to > be the same problem. And even though I can't read spanish, it looks like > only a work around was suggested. > > I can work around this further but does anyone have a solution using sscanf? > I'm not too clear on the acceptable syntax for the format string. Some > comments intimate that I could use regular expressions withing there, but it > doesn't seem to work either. > > Thanks in advance for any thoughts. > Glenn > > > > > <[EMAIL PROTECTED]> wrote in message > news:046401c217fb$56310b00$[EMAIL PROTECTED]... > > 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" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > 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 > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php