Yes:
$date = '26.01.2012';
echo date("d\<\s\u\p\>S\<\/\s\u\p\> F Y",strtotime($date));
I've probably overdone the escaping, but it works.
diafol
Rhod Gilbert Fan (ardav)
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
easiest way would be tokenize the string and use the tokens. Somewhere you can have array of Months. Also a simple function to check whether to use st, nd, rd or th
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Yes:
$date = '26.01.2012';
echo date("d\<\s\u\p\>S\<\/\s\u\p\> F Y",strtotime($date));
I've probably overdone the escaping, but it works.
That was easiest than my thought
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Just for completeness, I tried stripping as many backslashes as poss.:
$date = '26.01.2012';
echo date("d<\s\up>S</\s\up> F Y",strtotime($date));
I like cereal's a lot, but it messes up if you have other strings that contain 'rd' like Saturday in this:
echo preg_replace($a,'<sup>$0</sup>',date('l dS F Y',strtotime('28.01.2012')));
Changing to this does make it work though:
$a = array('/[d]st/','/[d]nd/','/[d]rd/','/[d]th/');
$date = '28.01.2012';
echo preg_replace($a,'<sup>$0</sup>',date('1 dS F Y',strtotime($date)));
diafol
Rhod Gilbert Fan (ardav)
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080