If Time is Less than 24 hours Show Hours/Minutes/Seconds...

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

User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: If Time is Less than 24 hours Show Hours/Minutes/Seconds

Post by Jonah Bron »

My guess is that there's a timezone issue. The timezone that your server is in is probably, oh say, maybe plus or minus 4 hours from you.

Try replacing

Code: Select all

$now = time();
$then = get_the_time('U');
With either

Code: Select all

$now = time() + (60*60*4);
$then = get_the_time('U');
or

Code: Select all

$now = time() - (60*60*4);
$then = get_the_time('U');
or

Code: Select all

$now = time();
$then = get_the_time('U') + (60*60*4);
or

Code: Select all

$now = time();
$then = get_the_time('U') - (60*60*4);
One of those for should work. I'm sort of tired, so I can't quite think hard enough to figure out which one :wink:
ccmovies
Forum Newbie
Posts: 15
Joined: Mon Oct 11, 2010 9:14 pm

Re: If Time is Less than 24 hours Show Hours/Minutes/Seconds

Post by ccmovies »

Excellent, I will try one of those in the morning. I am tired myself, and heading off to get some shut eye.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: If Time is Less than 24 hours Show Hours/Minutes/Seconds

Post by Jonah Bron »

Okay, I thought about it. It's either the second one or the third one. I think you want the third one. I think the second one will throw off date.
ccmovies
Forum Newbie
Posts: 15
Joined: Mon Oct 11, 2010 9:14 pm

Re: If Time is Less than 24 hours Show Hours/Minutes/Seconds

Post by ccmovies »

Jonah Bron wrote:Okay, I thought about it. It's either the second one or the third one. I think you want the third one. I think the second one will throw off date.
As far as I can tell, the third one works! Thank you so much!
Post Reply