Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   evaluate date where > 2 weeks ago (http://www.go4expert.com/forums/evaluate-date-2-weeks-ago-t1390/)

mcyi2mr3 13Sep2006 22:47

evaluate date where > 2 weeks ago
 
hi all i have a date on a php page and i need to check if that date (
in this format : 2006-06-04) is more than 2 weeks ago. How can i do
this most efficiently?

regards

marc

dux 5Oct2006 21:31

Re: evaluate date where > 2 weeks ago
 
if $date is the variable holing the date. Do the following

Code:

<?php
$timestamp=strtotime($date);//makes a timestamp from the date sting.
$twoweeks = mktime(0, 0, 0, date("m"), date("d")-14,  date("Y"));//Gets the timestamp for 14 days ago
if ($timestamp<$twoweeks)//if the date is over two weeks ago
.....


mcyi2mr3 6Oct2006 10:26

Re: evaluate date where > 2 weeks ago
 
The problem is already solved but anyways thanks for the help and I am looking forward to some more help in the near future in PHP as I am moving on with the language


All times are GMT +5.5. The time now is 10:36.