Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AlBDamned

macrumors 68030
Original poster
Mar 14, 2005
2,641
15
Hello,

Quick question for you guys. How do I get this ISO date format to read in full (Gregorian?) calendar?

At the moment, it's:

02-10-2006 14:28 because of this code: %d-%m-%Y %H:%M

However, I'd like it to be like this: Mon 2nd Oct 2006 14:28pm

It's for a forum I'm helping put together.

Any help (or screams of - "no you idiot it doesn't work like that...") gratefully received ;)
 
If you're using the PHP date() function, then the following should work OK...

date('l jS M Y G:Ia');

I don't think the PHP strftime() function has a way to produce the ordinal suffix for the date - st, nd, rd and so on.

The MySQL DATE_FORMAT() codes are different again. What function are you using to display the date?
 
02-10-2006 14:28 because of this code: %d-%m-%Y %H:%M

That looks like it's using strftime() formatting. Assuming that's what you have, a close format to what you want would be "%a %d %b %Y %l:%M%p" - that would give you "Mon 2 Oct 2006 2:28PM"

However, I'd like it to be like this: Mon 2nd Oct 2006 14:28pm
Do you really want to show 24-hour time with am/pm? If that's really what you want, you could replace the %l with %k .

If you're really looking for ISO 8601, "%Y-%m-%d %H:%M:%S" would be more like it.
 
iMeowbot said:
Do you really want to show 24-hour time with am/pm? If that's really what you want, you could replace the %l with %k .

If you're really looking for ISO 8601, "%Y-%m-%d %H:%M:%S" would be more like it.

Genius. I didn't want it as 14:28pm of course but that code works perfectly, iMeowbot. Any chance you could explain exactly what each figure represents? it doesn't look hugely different?

Thanks too, Interiority. :)
 

Attachments

  • Picture 10.JPEG
    Picture 10.JPEG
    9.5 KB · Views: 231
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.