Results 1 to 2 of 2

Thread: Is their a better alternative?

  1. #1
    Join Date
    Jul 2009
    Posts
    71

    Is their a better alternative?

    So I'm working on the display of my articles and currently I have all my articles saved with the date formatted with a datetime stamp so its like this yyyy-mm-dd hh:mm:ss so now here's what I was wondering on. I want the date to display but I want to reformat it so that it would display like this:

    Mon. DD(st/nd/rd/th), YYYY
    ex: Jan. 23rd, 2009

    I was thinking of going about it this way:

    PHP Code:
    $artMonth=substr($row[date],5,7);
    switch(
    $artMonth){
    case 
    01:
    $artMonth='Jan.';
    break;
    case 
    02:
    $artMonth='Feb.';
    break;
    case 
    03:
    $artMonth='Mar.'
    break;
    case 
    04:
    $artMonth='Apr.';
    break;
    case 
    05:
    $artMonth='May.';
    break;
    case 
    06:
    $artMonth='Jun.';
    break;
    case 
    07:
    $artMonth='Jul.';
    break;
    case 
    08:
    $artMonth='Aug.';
    break;
    case 
    09:
    $artMonth='Sep.';
    break;
    case 
    10:
    $artMonth='Oct.';
    break; 
    case 
    11:
    $artMonth='Nov';
    break;
    case12:
    $artMonth='Dec';
    break;
    default:
    $artMonth='Error';
    }

    $artDay=substr($row[date],9,11);

    switch (
    substr($artDay){
    case 
    0,4,5,6,7,8,9:
    $artDay="$artDay<sup>th</sup>,";
    break;
    case 
    1:
    $artDay="$artDay<sup>st</sup>,";
    break;
    case 
    2:
    $artDay="$artDay<sup>nd</sup>,";
    break;
    case 
    3:
    $artDay="$artDay<sup>rd</sup>,";

    $artYear=substr($row[date],0,4); 
    Let me know.

  2. #2
    Join Date
    Jun 2008
    Location
    cardiff
    Posts
    77
    YES!

    much simpler way mate.

    http://uk3.php.net/manual/en/function.date.php

    echo date("M dS Y");

    www.uk-site-design.co.uk stylish website development by Mke Dodd from £49.99

Similar Threads

  1. axure - free alternative
    By sevi in forum General Questions
    Replies: 0
    Last Post: 28 May 2009, 08:51 AM
  2. Alternative text
    By Bundyman in forum General Questions
    Replies: 1
    Last Post: 05 Oct 2005, 02:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •