This has bugged me for a while now.. i'm trying to calculate how many days have passed since unix epoch, but failed so far... I have tried like this:
floor($unix_timestamp / 86400);
intval($unix_timestamp / 86400);
but Im not getting the right values all the time, most of the time yes, but not all the time. The unix time stamp can be any given time since epoch. Are there any other ways to calculate this. (Or functions that I'm unaware of?)
thanks
-9902468
Simple calculation problem...
Moderator: General Moderators
whats the timestamp look like?
floor(time()/86400);
should work fine..and since i accidently misread your post
here it is broken down into years days hours minutes and seconds.
floor(time()/86400);
should work fine..and since i accidently misread your post
Code: Select all
<?
$years = floor(time()/31536000);
$days = (time()/86400) % 365;
$hours = (time()/3600) % 24;
$minutes = (time()/60) % 60;
$seconds = time() % 60;
echo "$years years, $days days, $hours hours, $minutes minutes, $seconds seconds";
?>