1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Rep Power

    Creating a unix time stamp

    Hi. This is a bit difficult(for me). I have 2 variables
    $date "2013-10-02"
    $time "15:45"

    I need to get back to a unix time stamp. Any ideas without breaking up the whole string and using mktime(which requires comma separated variables
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power

    use DateTime::createFromFormat() to parse the timestamp string. Then you can fetch the Unix timestamp with DateTime::getTimestamp().

    There's also strtotime(). However, it "guesses" the date format, which I personally don't like too much.
    Last edited by Jacques1; October 2nd, 2013 at 02:01 PM.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo