Hi there

I just need some clarification on how time is seen in PHP

1000 would equal 1 sec ?
and therefore 60 000 would equal 1 minute right ?
and 1 hour would be 3 600 000 ?

I somehow think I'm wrong.

Recommended Answers

All 5 Replies

if your talking about the function time() and a unix timestamp 1 = 1 second

Ok, so then 1 minute would be written as 60 and 1 hour as 3600 and 1 day as 86400?

the php time() function returns seconds. so one second = 1, one minute = 60 ect.

Ok, so then 1 minute would be written as 60 and 1 hour as 3600 and 1 day as 86400?

PHP can measure time in seconds using the time() function.
http://www.php.net/time

or you can use microtime() which is a measure of time in microseconds.
http://www.php.net/manual/en/function.microtime.php

The PHP timestamp is a measure of the number of seconds (or microseconds with microtime) that have elapsed since the Unix Epoch (January 1 1970 00:00:00 GMT). So if you want to work with dates before the Epoch you will have to cater for that in your code. It also cannot measure dates in the future that require more bits then allocated for its datatype - not sure what that date is exactly.

Therefore, normally the PHP time functions are used to get the current date, and make calculations. But if you want to save the resulting date, its better to save it as an actual date if its range may lie outside the limitation of the PHP timestamp.

Thanks for the response. I had a look at the manual under time but it didn't make it quite clear.

Thanks once again ;)

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.