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
    Jun 2002
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DATETIME -> time()

    In the mysql database I'm currently working on, there's a DATETIME field which has the format 0000-00-00 00:00:00. How can I convert that to have the same format as time(), so I can do calculations with the DATETIME field using the time()-function?
    Last edited by Pompiuses; 12-04-2003 at 10:06 AM.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    if you mean PHP time(); (eg a unix timestamp) , you can

    "SELECT UNIX_TIMESTAMP('your_date_ field') as unixtime FROM $table"


    else if you mean mysql's built in date juggling functions any valid MySQL timestamp type can be munged with the inbuilt MySQL date handling functions, you don't need to convert them.

    If you can get MySQL to do the date arithmetic for you then do so as its much faster!
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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