Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date formatting 1

Status
Not open for further replies.

sinbadly

Technical User
Mar 16, 2006
126
GB
I'd like to include the formatting in a date field.

This doesn't work, but something like this ....

printf("<p><div id=\"date2\"> Updated: %s</div><br>", date($myrow["updated"], "D d/m/Y");

The basic code that works ok is

printf("<p><div id=\"date2\"> Updated: %s</div><br>", $myrow["updated"]);

but of course there's no formatting there. Anyone know how I could do it without putting a DATE_FORMAT() in the select query, please?
 
i don't think you are using the date function correctly.
the format string is usually the first parameter.
 
Hi Justin

Yes, I know I have it wrong. I'm wondering how it ought to look. I mean where the formatting goes on the code. I will try it changed around. Cheers
 
Another nit. You need two ) at the end.

Duplicate your working line, comment out one copy and monkey with the other.
 
The PHP manual should answer all your questions about the DATE function.

Here: [blue] date() [/blue]

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
is $myrow["updated"] a unix timestamp? in which case just reversing them in the date function is fine.

if it is a mysql date of YYYY-MM-DD then you'd want something like

Code:
echo date("D, j n, Y", strtotime($myrow['updated']));

the date() function is so rich that i am constantly referring back to the manual page to see what the right parameters are to make it sit up and beg. in fact, i even have a link to it on my firefox toolbar!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top