开发者

How to get past day from current time in php

开发者 https://www.devze.com 2022-12-19 04:56 出处:网络
I want to calculate whats the date 20 yrs back fromcurrent time in php.How can do that.I am not able to figure this out in a proper manner. Scenario is:

I want to calculate whats the date 20 yrs back from current time in php.How can do that.I am not able to figure this out in a proper manner. Scenario is:

I am having a column dob in mysql. Now i want to retrieve all the users who age is more than 20yrs and less than 25 yrs. I am using doctrine orm

Edit

Its working fine but giving a warning:

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of开发者_高级运维 those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in C:\xampp\htdocs\fanyer\test.php on line 11 Today: 2010-02-07


Try:

echo 'Today: '. date('Y-m-d') ."\n";
echo 'Today: '. date('Y-m-d', strtotime('-20 year')) ."\n";

See: http://php.net/manual/en/function.time.php

Edit:

About the warning: either ignore it, or explicitly set the time-zone using

date_default_timezone_set('...your zone here...');

See: http://php.net/manual/en/function.date-default-timezone-set.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号