User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,969 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,627 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 132 | Replies: 5 | Solved
Reply
Join Date: Oct 2007
Posts: 175
Reputation: Venom Rush is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Junior Poster

Time in terms of PHP

  #1  
Jul 18th, 2008
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.
This user has a spatula. We don't know why, but we are afraid.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 601
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 53
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Master Poster

Re: Time in terms of PHP

  #2  
Jul 18th, 2008
if your talking about the function time() and a unix timestamp 1 = 1 second
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Oct 2007
Posts: 175
Reputation: Venom Rush is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Junior Poster

Re: Time in terms of PHP

  #3  
Jul 18th, 2008
Ok, so then 1 minute would be written as 60 and 1 hour as 3600 and 1 day as 86400?
This user has a spatula. We don't know why, but we are afraid.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 550
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 55
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: Time in terms of PHP

  #4  
Jul 18th, 2008
the php time() function returns seconds. so one second = 1, one minute = 60 ect.
Last edited by kkeith29 : Jul 18th, 2008 at 7:30 am.
Reply With Quote  
Join Date: Sep 2005
Posts: 678
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 5
Solved Threads: 39
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: Time in terms of PHP

  #5  
Jul 18th, 2008
Originally Posted by Venom Rush View Post
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Oct 2007
Posts: 175
Reputation: Venom Rush is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Venom Rush's Avatar
Venom Rush Venom Rush is offline Offline
Junior Poster

Re: Time in terms of PHP

  #6  
Jul 18th, 2008
Thanks for the response. I had a look at the manual under time but it didn't make it quite clear.

Thanks once again
This user has a spatula. We don't know why, but we are afraid.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC