Jump to content


Photo

Milliseconds to time and Date


  • Please log in to reply
5 replies to this topic

#1 BDwinsAlt

BDwinsAlt
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 03 October 2006 - 11:39 PM

Can anyone lead me in the right direction to converting milliseconds to the correct time and date?
I am using a bot in this game that stores the last login time in milliseconds, I haven't been able to get the exact code I need to convert this into H:M:S on MM:DD:YYYY

Thanks.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 03 October 2006 - 11:43 PM

Please show an example time string, so we can see what it exactly is.

me!

#3 BDwinsAlt

BDwinsAlt
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 03 October 2006 - 11:46 PM

Last Login: 1159916451

        $lastseen = $row['lastseen'];
        echo('<br /> Last login: ' . $lastseen . '<br />');


#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 October 2006 - 11:56 PM

That's not milliseconds, that number is the number of seconds that have elapsed since the base time of 1/1/1970. To see what it is in readable notation, use the date() function:
<?php
$str = 1159916451;
echo date('l,F j, Y  g:i a',$str);
?>

Ken

#5 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 03 October 2006 - 11:57 PM

like so, (it a timestamp)

<?

echo date ( 'H:i:s \o\n m:d:Y', 1159916451 );

?>


me!

#6 BDwinsAlt

BDwinsAlt
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 October 2006 - 12:01 AM

This worked! Thanks!  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users