PHP Date Format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cfdarby
Forum Newbie
Posts: 1
Joined: Wed Nov 20, 2002 1:06 am
Location: Perth WA

PHP Date Format

Post by cfdarby »

I have a variable created from data taken out of a mySQL database the variable is a date value in the format YYYY/MM/DD i need to beable to format this date and also retrieve a unix timestamp from it, ive looked all through the PHP documentation and couldnt find anything to allow me to format a variable, maybe i missed something, can someone point me in the right direction

Chris
rlogin
Forum Newbie
Posts: 19
Joined: Fri Oct 18, 2002 2:39 am

Date Format...

Post by rlogin »

To format a Unix Time stamp use strftime() function.
To format a GMT time value, use gmdate().
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you're storing the date in a date or timestamp field in MySQL (which makes life a lot easier) you can easily format it using MySQL when you retrieve it:
http://www.mysql.com/doc/en/Date_and_ti ... tions.html

Mac
Post Reply