Convert seconds to time in php

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
valmerin
Forum Newbie
Posts: 6
Joined: Mon Nov 02, 2009 5:29 pm

Convert seconds to time in php

Post by valmerin »

Ok i grabbed the server time, it gives me seconds in a unix time stamp i think. But i took the end time i wanted - current server time and i get a smaller string of seconds. But im having trouble convertering it to a time. I dont want a date and time i just want to convert it to dd:hh:mm:ss.

Could some one give me some insight on how to go about doing this pls. Thank you for your help.
AlanG
Forum Contributor
Posts: 136
Joined: Wed Jun 10, 2009 1:03 am

Re: Convert seconds to time in php

Post by AlanG »

Use the php date function to format unix timestamps.

Code: Select all

$unixTime = 1234567890;
 
$myTime = date('d:H:i:s', $unixTime);
valmerin
Forum Newbie
Posts: 6
Joined: Mon Nov 02, 2009 5:29 pm

Re: Convert seconds to time in php

Post by valmerin »

Ty vm that was exactly what i needed
Post Reply