+ Post New Thread
Results 1 to 10 of 10
Coding Thread, Full time and Date to Unix format in Coding and Web Development; I need to covent: Sun Jun 28 21:03:15 +0000 2009 To the equivalent unixtime stamp?...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30

    Full time and Date to Unix format

    I need to covent:

    Sun Jun 28 21:03:15 +0000 2009

    To the equivalent unixtime stamp?

  2. #2

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,071
    Thank Post
    160
    Thanked 929 Times in 730 Posts
    Blog Entries
    3
    Rep Power
    274
    1246222995

    That should be it

  3. #3

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    PHP? I'm sure I've sent you that before

    Edit: it's strtotime().
    Last edited by powdarrmonkey; 28th June 2009 at 11:06 PM.

  4. #4

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,198
    Thank Post
    404
    Thanked 627 Times in 573 Posts
    Rep Power
    182
    Online Conversion - Unix time conversion

    Might help.

    What James has given is correct.

  5. #5

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30
    powdarrmonkey my repetative saviour!

  6. #6

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30
    The problem I have is that I need to insert into a table where the date is greater than the latest date stored in database:

    Code:
    INSERT INTO backup where $thedate > $latestdate VALUES('', '$name', '$content', '$thedate';
    Where the dates have been stored as:

    Sun Jun 28 22:03:41 +0000 2009

    So


    Code:
    INSERT INTO backup where 
    Sun Jun 28 22:03:41 +0000 2009 > 
    Sun Jun 28 22:00:21 +0000 2009 VALUES('', '$name', '$content', '$thedate';
    But can i compare dates like this?

  7. #7
    mossj's Avatar
    Join Date
    Dec 2008
    Location
    Leicester
    Posts
    1,466
    Thank Post
    157
    Thanked 189 Times in 174 Posts
    Rep Power
    52
    Why can't you just convert both to unix, W3schools seems to say to use "mktime()" to do this

    http://www.w3schools.com/php/func_date_gmmktime.asp - might be useful
    http://www.w3schools.com/php/func_date_strtotime.asp - or for strtime
    Last edited by mossj; 28th June 2009 at 11:24 PM.

  8. #8

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    You can't compare complex dates like that in MySQL, only dates stored as integers. You'll have to do a select from the database, use strtotime() on the retrieved date, compare it to time(), and do an insert if appropriate.

  9. #9
    mossj's Avatar
    Join Date
    Dec 2008
    Location
    Leicester
    Posts
    1,466
    Thank Post
    157
    Thanked 189 Times in 174 Posts
    Rep Power
    52
    Quote Originally Posted by powdarrmonkey View Post
    You can't compare complex dates like that in MySQL, only dates stored as integers. You'll have to do a select from the database, use strtotime() on the retrieved date, compare it to time(), and do an insert if appropriate.
    It looks like to me he has already pulled them into PHP varibles.

  10. #10

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    So he has. In that case, just compare strtotime($thedate) and strtotime($latestdate).

SHARE:
+ Post New Thread

Similar Threads

  1. Windows XP SP3 change to Date/Time format
    By itwasntme in forum Windows
    Replies: 7
    Last Post: 11th July 2008, 01:18 PM
  2. [CLOSED] Bug/Error: Date/Time is wrong.
    By contink in forum EduGeek.net Site Problems
    Replies: 2
    Last Post: 3rd March 2008, 02:44 PM
  3. Win2k3 DC time server for unix?
    By Oops_my_bad in forum Windows
    Replies: 4
    Last Post: 17th January 2008, 10:07 PM
  4. Who works term time only? How many full time?
    By gwendes in forum General Chat
    Replies: 45
    Last Post: 10th February 2007, 05:38 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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