Get Hour ?

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
Death
Forum Newbie
Posts: 17
Joined: Tue Apr 19, 2005 11:52 am

Get Hour ?

Post by Death »

Hi guys,

I need the current hour in [0,23] format, the local server time is just fine. What's the best (fastest) way to get this value ?

Thanks.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Why don't you try benchmarking it yourself? Don't take our word for it: do it!
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

check out the date function in PHP
Death
Forum Newbie
Posts: 17
Joined: Tue Apr 19, 2005 11:52 am

Post by Death »

I don't know how to benchmark PHP, that's why.

When I benchmark C++ I run a Performance Counter so it's pretty straightforward.

Also, I develop my PHP on a WinXP machine then upload it to my web server so it's not so easy to benchmark.

Anyway, I'm going to do it this way for now:

Code: Select all

$hour=date("H");
settype($hour,"integer");
Take care.
Post Reply