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

Recommended Answers

All 4 Replies

is the value of unixtime 3600 = 1 hour

edit your timezone in php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Manila" //edit your timezone here

click here for the rest of timezone http://php.net/manual/en/timezones.php, after your edit save changes and restart your PHP server

the OP is 'interesting'
but a fine example of what not to do

write what you wish to achieve,
you have a function unix2data that you do not define for anyone to see,
nor do you explain the expected results, or the expected inputs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.