Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    82

    Exclamation Unanswered: Unix Timestamp Problems

    I am trying to "convert" a unix timestamp into a nicer to read date. I know this is easy but there is slightly more to it:

    I have taken a time in the future which has been written into the database (MySQL) and set it as the variable $dbtime. I also have the variable $time which is equal to time(). I then want to find the difference between the two and then show it as a time. For example:
    PHP Code:
    $time time(); ##This is the current time as a unixts
    $dbtime $row['futuretime']; ##This is the time in the future written beforehand

    $timeleft $dbtime $time##This is the difference between the two, the value I want to convert! 
    I assumed it would be:

    PHP Code:
    $timeleftconvert date('H:i:s'$timeleft); 
    However if the $timeleft is 2minutes for example the time will be echoed as "19:02:00" if it was 3 minutes it would be "19:03:00" etc...The code then does certain functions when the 2/3 minutes are up. If the time left is shown as 19:02:00 then after 2 minutes it will go on to complete the functions. IT WILL NOT TAKE 19 HOURS. I realised it would be possible to leave the hours out and then I would look fine however some of the future times are 24hrs however it still says 19hrs when converted...if this problem doesn't make sense and it wouldn't normally be a problem then maybe it is an error with the insertion of the future time into the database...


    Anyway, thanks in advance for any leads,


    ~jordan

  2. #2
    Join Date
    Aug 2004
    Posts
    82
    Ok I solved this problem my self... I was just being stupid at the time and using the wrong variables...the above would usually work...just another mistype

    Cheers anyway.

    ~Jordan

Posting Permissions

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