Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 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
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    http://php.net/manual/en/function.strtotime.php

    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'])); 

  • Users who have thanked BluePanther for this post:

    tomharto (09-12-2011)

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Ahh, that worked, thank you

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    No problem . The manual has a full list of time/date formats strtotime will accept, just as an FYI


  •  

    Posting Permissions

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