Sign in to follow this  

[web] Time from a timestamp in PHP

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a UNIX timestamp that I need to convert into hours:minutes:seconds. I tried using gmstrftime("%H:%M:%S", $timestamp) but that does not return the total hours. An example is say the timstamp equals 54 hours, 36 minutes, 54 seconds in GMT, what function in PHP would return that correctly? Thanks!

Share this post


Link to post
Share on other sites
Er, timestamp's do not equal 54 hours, 36 minutes, 54 seconds, an interval, however, does.

Are you wanting to get the interval from one point in time to another? Or are you wanting to get the hour, minutes and seconds from a timestamp? I ask this because it seems you're wanting an interval but are pulling it based on a single timestamp with no other point of reference, which an interval needs (unless you're counting from the beginning of time).

Share this post


Link to post
Share on other sites
Quote:
Original post by Mathachew
Er, timestamp's do not equal 54 hours, 36 minutes, 54 seconds, an interval, however, does.

Are you wanting to get the interval from one point in time to another? Or are you wanting to get the hour, minutes and seconds from a timestamp? I ask this because it seems you're wanting an interval but are pulling it based on a single timestamp with no other point of reference, which an interval needs (unless you're counting from the beginning of time).


Ah yes, you're right. I'll try to explain more what I need then to see if anyone has a solution. I'm calculating the interval between two times and adding them to a timestamp(I first convert the two times into timestamps). At the end I then have the timestamp with the total time of all the intervals added together, correct? If that's true then I need that time returned in the format of total hours, minutes, and seconds. What would be the best way to go about doing this?

I appreciate the help so far.

Share this post


Link to post
Share on other sites
Quote:
Original post by Third
Ah yes, you're right. I'll try to explain more what I need then to see if anyone has a solution. I'm calculating the interval between two times and adding them to a timestamp(I first convert the two times into timestamps). At the end I then have the timestamp with the total time of all the intervals added together, correct? If that's true then I need that time returned in the format of total hours, minutes, and seconds. What would be the best way to go about doing this?

I appreciate the help so far.


http://aidan.dotgeek.org/repos/?file=Duration.php

This script returns the duration based on the number of seconds passed to it. Hope this helps.

Share this post


Link to post
Share on other sites

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this