You are here: Re: More noob nonsense - output format for a timestamp date variable « PHP Programming Language « IT news, forums, messages
Re: More noob nonsense - output format for a timestamp date variable

Posted by Joshie Surber on 04/26/06 06:40

date() requires a unix timestamp, which is differant from the mysql
timestamp. therefore, you must create one:
$yy = substr($lastdate, 0, 4);
$mm = substr($lastdate, 4, 2);
$dd = substr($lastdate, 6, 2);
$hh = substr($lastdate, 8, 2);
$mm = substr($lastdate, 10, 2);
$ss = substr($lastdate, 12, 2);
$date = mktime($hh, $mm, $ss, $mm, $dd, $yy);
$whatYouWant = date('n/j/y', $date);

hph wrote:
> Okay, another trivial matter that I can't solve.
>
> I have a variable - $lastdate - that is the latest date any record in a
> MySQL database was updated. Its MySQL format is TIMESTAMP.
>
> If I say [echo $lastdate] I get the output I'd expect - 20060424221549
> which is a YYYYMMDDHHMMSS format.
>
> I'd like to be able to display that using a format of mm/dd/yy with no
> leading spaces on the month and day. I don't know what the php command
> is to do this. In other words, I'm trying to display a variable -
> $lastdate - formatted a certain way. I know that the formatting string
> n/j/y will get my output looking as I'd like, but I can't figure out how
> to apply that to my variable.
>
> Thanks to those who've helped me with my questions the last two days.
> This seems to be the last piece of information I can't find right now.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация