convert date

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
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

convert date

Post by cto1mac »

How do I convert a date 12 September 2003 to the day of the year?? I know that if I use date("z") that it will give me current day of the year but I need to convert find out how to convert that day to the long date and vice versa.

Thanks
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

give expamples... is the date in a database?
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

Try something like this:

Code: Select all

date('d', strtotime('12 September 2003'))
if you want the 'day of the year' you will probably have to do some more calculations. If it's from a mysql database, I believe that you can that format using the date/time functions in the mysql manual
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

date('z',strtotime('12 September 2003')) should give you the day of the year of Sept. 12, 2003.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply