Quick Newbie Question about dates...

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
alisonjj
Forum Newbie
Posts: 3
Joined: Thu Jan 08, 2009 1:19 pm

Quick Newbie Question about dates...

Post by alisonjj »

How do I modify the code below to work with hours instead of days:

function isViewableDate($current_date, $min_notice, $max_notice) {
$min_days = -3; //ideally I would like $min_hours = -75;
$min_date = mktime(0,0,0, date('m'), date('d') + $min_days);
if ($current_date > $min_date)
{
return true;
}
if ($current_date < $min_date)
{
return false;
}

Thanks!
Alison
Randwulf
Forum Commoner
Posts: 63
Joined: Wed Jan 07, 2009 7:07 am

Re: Quick Newbie Question about dates...

Post by Randwulf »

Not sure what you're trying to do here, maybe I'm just being noob too. But I believe mktime returns the seconds since 1970 so if you wanted hours, couldn't you just multiply it by 3600? Again, not quite sure what you want.
alisonjj
Forum Newbie
Posts: 3
Joined: Thu Jan 08, 2009 1:19 pm

Re: Quick Newbie Question about dates...

Post by alisonjj »

Hi,
I would like the function to be "true" when todays date falls within 75 hours ago (not 3 days ago as it is now). And the function to be "false" if todays dates is past 75 hours ago.

Thanks for your reply :)

Alison
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Quick Newbie Question about dates...

Post by califdon »

alisonjj
Forum Newbie
Posts: 3
Joined: Thu Jan 08, 2009 1:19 pm

Re: Quick Newbie Question about dates...

Post by alisonjj »

Thanks, I figured it out with the help of that tutorial!!!

Alison
Post Reply