SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation coveting date to timestamp

    Hi there,

    I just need the code that will convert the date from the numerical format (shown below) into Unix timestamp format
    Code:
    DD MM YYYY --> 24 02 2007
    Can anyone please provide me the code, or refer to a website where I could get it...

    Thanks

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $date '02 24 2007';
    $date explode(' '$date);
    $date implode('-', array($date[2], $date[0], $date[1]));
    echo 
    strtotime($date); 
    It rearranges your string into YYYY-MM-DD then uses the strtotime function to convert to a time stamp.

  3. #3
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code, Mike

  4. #4
    SitePoint Addict pkSML's Avatar
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TMTOWTDI

    PHP Code:
    <?php
    $db_date 
    "13 02 2007"// Date from database
    list($day$month$year) = split(' '$db_date);
    $timestamp mktime(000$month$day$year); // Returns UNIX timestamp for $db_date
    echo $timestamp?>
    Derived from: http://stephen.calvarybucyrus.org/codebin/10
    -Stephen

    Get a LitlURL to this page!


Bookmarks

Posting Permissions

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