Web Analytics Made Easy -
StatCounter Convert date (DD/MM/YYYY) into timestamp - CodingForum

Announcement

Collapse
No announcement yet.

Convert date (DD/MM/YYYY) into timestamp

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert date (DD/MM/YYYY) into timestamp

    I need to convert a date in the format dd/mm/yyyy (date format got from jQuery datepicker) and i need to convert it to a timestamp.

    I tried
    PHP Code:
    time($_POST['datepicker']); 
    but that didnt work, how would i do this?

  • #2


    strtotime($_POST['datepicker']) should return a valid timestamp I think. I would check it though.

    Easy way to check:
    PHP Code:
    // Both should echo the same thing
    echo $_POST['datepicker']."\n";
    echo 
    date("d/m/Y"strtotime($_POST['datepicker'])); 
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

    Comment


    • #3
      Ahh, that worked, thank you

      Comment


      • #4
        No problem . The manual has a full list of time/date formats strtotime will accept, just as an FYI
        Useful function to retrieve difference in times
        The best PHP resource
        A good PHP FAQ
        PLEASE remember to wrap your code in [PHP] tags.
        PHP Code:
        // Replace this
        if(isset($_POST['submitButton']))
        // With this
        if(!empty($_POST))
        // Then check for values/forms. Some IE versions don't send the submit button 
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎