ISO Date format Q

Discussion in 'Web Design and Development' started by AlBDamned, Nov 13, 2006.

  1. AlBDamned macrumors 68030


    Mar 14, 2005

    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 ;)
  2. Interiority macrumors member

    Nov 9, 2001
    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?
  3. iMeowbot macrumors G3


    Aug 30, 2003
    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"

    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.
  4. AlBDamned thread starter macrumors 68030


    Mar 14, 2005
    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. :)

    Attached Files:

Share This Page