www.webdeveloper.com
Results 1 to 2 of 2

Thread: How do I easily turn this date into separate variables?

  1. #1
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    364

    Question How do I easily turn this date into separate variables?

    It sounds easy. I've done it before, but when I browse the web for a solution, I turn up nothing.

    I have a string like this: 04/07/2012

    I want to turn this into a month, day, and year variable. How do I do that?

    Thanks,
    M

  2. #2
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    364

    Question

    Argh! Answered my own question.

    PHP Code:
    <?php
    // Delimiters may be slash, dot, or hyphen
    $date "04/30/1973";
    list(
    $month$day$year) = split('[/.-]'$date);
    echo 
    "Month: $month; Day: $day; Year: $year<br />\n";
    ?>
    That took some searching.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles