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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    478
    Thanks
    7
    Thanked 3 Times in 3 Posts

    convert 2012-01-08 16:13:54 to time()

    How do I convert the following format to unix time ?

    2012-01-08 16:13:54

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    First you need to explode the string by the space.

    Then you need to explode the date by the /'s
    Then you need to explode the time by the :'s

    Then you need to re-arrange all those 6 variables and run them through mktime()

    You may also be able to feed it into strtotime() however that isn't as reliable (it won't take some timestrings according to the PHP versions and unlike most things, the php manual doesn't state which versions support what timestrings - EG "first day of <month>" doesn't appear to work below versions 5.3.0)
    I can't really think of anything to write here now...


  •  

    Posting Permissions

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