Jump to content

[SOLVED] Help with date formatting


jaikob

Recommended Posts

no, that is MySQL. the reason i suggest using MySQL functions is because it takes far less work than PHP - MySQL is used to manipulating its own format. to implement it, you'd go:

 

SELECT stuff, DATE_FORMAT(date_field, 'string according to MySQL manual') AS formatted_date FROM table

 

formatted_date will now contain the format you're looking for. have a look in the MySQL manual under "Functions and Operators", the section for date/time functions, for a description of what that second parameter needs to look like.

 

EDIT:  linkies - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

Edit:

 

duh, I forgot the colons.

 

Thank you so much for your help!

 

no, that is MySQL.  the reason i suggest using MySQL functions is because it takes far less work than PHP - MySQL is used to manipulating its own format.  to implement it, you'd go:

 

SELECT stuff, DATE_FORMAT(date_field, 'string according to MySQL manual') AS formatted_date FROM table

 

formatted_date will now contain the format you're looking for.  have a look in the MySQL manual under "Functions and Operators", the section for date/time functions, for a description of what that second parameter needs to look like.

 

EDIT:  linkies - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

it would take a fair bit of string manipulation to format it using PHP.  what did the query look like, and what error were you getting?

 

if you're insistent on using PHP, have a look at the following functions:

 

explode()
substr()
str_replace()
implode()

 

you may end up using any or all of them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.