Need help with some date logic...

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
tarron
Forum Newbie
Posts: 13
Joined: Thu May 23, 2002 12:09 pm

Need help with some date logic...

Post by tarron »

I'm trying to figure out how to calculate the date of the end of the week (saturday) based on the current date. For example, if the current date is 05-23-2002 (gmDate('m-d-Y')) getting the a result of 05-24-2002.

Any ideas?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<?php $date = getdate();
$date = date('Y-m-d', mktime(0, 0, 0, $dateї'mon'], $dateї'mday']+(6-$dateї'wday']), $dateї'year']));
print($date);
?>
prints the next saturday
tarron
Forum Newbie
Posts: 13
Joined: Thu May 23, 2002 12:09 pm

Thanks a lot.

Post by tarron »

I appreciate the help.
Post Reply