Results 1 to 5 of 5

Thread: Display day of week from date [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Display day of week from date [RESOLVED]

    I have a list of dates in the following format:
    14/Jun/2003
    18/Jul/2003
    09/May/2003
    ...
    This list will keep continuing to grow so it can not be hard coded.

    I would like to be able to determine from this date format what the day of the week it is (Mon, Tues, Wed, etc...). Is this even possible? I know that if I had the month in a numberic value I could use:
    getdate(mktime(0,0,0,$month, $day, $year)).

    My second question would be then, Is it possible to convert a month, Jul to 07?

    Thanks for the help in advance.
    Last edited by lleemon; Jul 18th, 2003 at 12:38 PM.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why are you saving the date like that?

    If you would save it in any kind of normal format, the php date() function would answer your two questions in one line of code.

    But they cannot understand that format.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Example:

    Code:
    <?php
        $date = "14/06/2003";
    
        echo "The day of the week is " . date('D', strtotime($date)) . ".<br>";
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I suppose you could always pull this number:

    Code:
    <?php
        $date = "14/Jun/2003";
    
        $dp = explode('/', $date);
        $newdate = "$dp[1] $dp[0], $dp[2]";
    
        echo "The day of the week is " . date('D', strtotime($newdate)) . ".<br>";
        echo "The month number is " . date('m', strtotime($newdate)) . ".<br>";
    ?>
    Last edited by The Hobo; Jul 18th, 2003 at 12:56 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830
    The Hobo,
    Works very nice!

    Thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width