c4rdinal Posted July 24, 2009 Share Posted July 24, 2009 Hi, I have a APPLICANT table with date element field (expiry_date). Ex. Expiry date = 07.11.2009 Then, I would like to have a table ( JOB ALERT) field, alert_on_expiry, which would contain the extracted value of "two months" prior to the expiry date. Meaning the value of alert_on_expiry should always be 2 months. So that all job contract expiring in two months will be posted on my JOB ALERT table. I really stuck with this problem. Can anyone please help me create code in php to extract this value? Thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/167222-date-extraction/ Share on other sites More sharing options...
ignace Posted July 24, 2009 Share Posted July 24, 2009 $time = strtotime($row['expiry_date']); $expiry_date = date('d-m-Y', $time); list($day, $month, $year) = explode('-', $expiry_date); $month -= 2;// 2 months earlier if ($month < 1) { $year -= 1; $month = 12 - abs($month); } $alert_on_expiry = date('d-m-Y'/*SQL date format*/, mktime(0, 0, 0, $month, $day, $year)); Quote Link to comment https://forums.phpfreaks.com/topic/167222-date-extraction/#findComment-881798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.