finding the nearest date()

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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

finding the nearest date()

Post by pelegk2 »

say i am on friday or saturday
and i want to find the closest sunday or last fridat date's
how can i do it?
thnaks in advance
peleg
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

strtotime() makes it pretty easy
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

first thanks

Post by pelegk2 »

second i tried to find :
have a look at the GNU manual page titled Date Input Formats.
and the given link isnt working :(
now maybe another place to look for then the given link in the manual?

third : for example here it now friday and i did :

Code: Select all

strtotime ("near Sunday")
and instead of reciving 16/1/2005 i recived 23/1/2005
why is that?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

	echo date('Y-m-d', strtotime('-1 week last thursday')) . "\n";
	echo date('Y-m-d', strtotime('next sunday')) . "\n";
	echo date('Y-m-d', strtotime('this sunday')) . "\n";

?>

Code: Select all

2005-01-06
2005-01-23
2005-01-16
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

first thnaks alot

Post by pelegk2 »

second where can i find : the
"Date Input Formats"?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply