Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Format a date

Posted 23 Apr 2009 20:07:31
1
has voted
23 Apr 2009 20:07:31 Chest Rockwell posted:
I am moving over from ASP to PHP and I am having a few teething troubles. I have a date field (currently a timestamp) in my mysql database and would like to show it on my php page as following example shows 23rd April 2009. However I would like to be able to make the rd part of the date a subscript (well I am actually going to use css to format it but for arguement sake a subscript). What would be the best way to go about this?

Decker

Replies

Replied 18 May 2009 18:19:51
18 May 2009 18:19:51 Roddy Dairion replied:
There's a few ways of doing this in php but since you're mentioning that you're calling this from a Mysql Database in your query just simply add this

date_format(fieldname,'%d%S %F %Y') as `fieldname`

just replace fieldname with the fieldname being used in your table.
Replied 22 May 2009 16:15:20
22 May 2009 16:15:20 Patrick Woldberg replied:
In php it would become like:
<?php echo date('jS F Y'); ?>

Reply to this topic