convert unix to day and hour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srdva59
Forum Commoner
Posts: 77
Joined: Sun Feb 15, 2009 10:58 am

convert unix to day and hour

Post by srdva59 »

hi,

i want convert the time stamp unix format to hours and days

i have this:

$date = trim(date('H:i:s', $ofwhat));

$ida = trim(date('d', $ofwhat)) -1;

if ($ida >0) {if ($ida==1) { $dia= $ida. " day, "; } }

if ($ida >0) { if ($ida>1) { $dia= $ida. " days, "; } }


this work fine in my local pc that have php 4
if i put this: echo unix2data(3600,4); they return 1 hour that is correct

but when i put in the server running php 5
the echo unix2data(3600,4); return 19 hours!
what i doing wrong?
thanks a lot for your help
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: convert unix to day and hour

Post by Darhazer »

probably it takes into account the time zone. Try using gmdate instead of date
Post Reply