Re: [PHP] Problems reformatting Unix timestamp with strftime
On Thu, 15 Feb 2001 at 17:57:43, Rog <[EMAIL PROTECTED]> writes >He's probably gotten his timestamp from a database, in which case the >easiest solution is usually reformat the timestamp when collecting it >from the database rather than within PHP. > >(MySQL) Example : >select UNIX_TIMESTAMP(timestamp); > >Then the timestamp will be properly formatted for PHP's date command. Hooray! This works, thanks! -- Steven "Sponges grow in the ocean... that *kills* me. I wonder how much deeper they'd be if that didn't happen." - Steven Wright -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems reformatting Unix timestamp with strftime
On Fri, 16 Feb 2001 at 02:03:42, [EMAIL PROTECTED] writes >> with the same effect - 20010213173654 becomes >> Monday, 18th January 2038. Is there a problem with the way I'm passing >> the timestamp to the date command? > >Your timestamp looks bogus. On normal systems this can only be a 32 bit >integer and there will be an overflow at that time. The timestamp is created within MySQL and means 17:36:54 on 13th February 2001. I suppose I was wrong in assuming that this is Unix format? In which case, is there a way I can process such a date from MySQL directly using a command like strftime() or date()? Or is it an uncommon timestamp format to have to process? If there isn't a way of processing this with a simple command I'll admit defeat and use substrings ;-) Thanks again. -- Steven "Sponges grow in the ocean... that *kills* me. I wonder how much deeper they'd be if that didn't happen." - Steven Wright -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems reformatting Unix timestamp with strftime
[EMAIL PROTECTED] wrote: >Your timestamp looks bogus. On normal systems this can only be a 32 bit >integer and there will be an overflow at that time. His timestamp is perfectly fine, it's just in the wrong format. His is formatted to YearMonthDayHourMinuteSecond and you (and the date function for that matter) are assuming a UNIX timestamp of seconds since 1970. He's probably gotten his timestamp from a database, in which case the easiest solution is usually reformat the timestamp when collecting it from the database rather than within PHP. (MySQL) Example : select UNIX_TIMESTAMP(timestamp); Then the timestamp will be properly formatted for PHP's date command. -- Visit the Gates Motel webgame: http://www.gameslate.com/gatesmotel/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems reformatting Unix timestamp with strftime
On Fri, Feb 16, 2001 at 12:32:47AM +, Steven Hirschorn wrote: > On Fri, 16 Feb 2001 at 01:08:58, [EMAIL PROTECTED] writes > >You haven't read the PHP Manual carefully: > > > >http://php.net/mktime > >http://php.net/date > > Thanks for the speedy reply! I've tried using: > date("l, jS F Y",$lastmodified) > > with the same effect - 20010213173654 becomes > Monday, 18th January 2038. Is there a problem with the way I'm passing > the timestamp to the date command? Your timestamp looks bogus. On normal systems this can only be a 32 bit integer and there will be an overflow at that time. -Egon -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ http://www.php-buch.de/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems reformatting Unix timestamp with strftime
On Fri, 16 Feb 2001 at 01:08:58, [EMAIL PROTECTED] writes >You haven't read the PHP Manual carefully: > >http://php.net/mktime >http://php.net/date Thanks for the speedy reply! I've tried using: date("l, jS F Y",$lastmodified) with the same effect - 20010213173654 becomes Monday, 18th January 2038. Is there a problem with the way I'm passing the timestamp to the date command? -- Steven "Sponges grow in the ocean... that *kills* me. I wonder how much deeper they'd be if that didn't happen." - Steven Wright -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems reformatting Unix timestamp with strftime
On Fri, Feb 16, 2001 at 12:04:01AM +, Steven Hirschorn wrote: > I've checked this in the PHP documentation and done a scan of the > archive to try to work out where I am going wrong but have failed. I > know I could fix this problem by using substrings and processing them, > but PHP has a simpler function which should work. Shouldn't it? > > In my database a record has a timestamp of: > 20010213173654 > > I extract the timestamp with a select statement, and process it with: > > strftime("%A, %e %B %Y", $lastmodified) (where lastmodified is the > variable containing the timestamp) > > and it produces the output: > Monday, 18 January 2038 > > Does anyone know why PHP isn't interpreting the timestamp correctly? I > can't work out how it could misinterpret the timestamp like this... You haven't read the PHP Manual carefully: http://php.net/mktime http://php.net/date -Egon -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ http://www.php-buch.de/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]