Jump to content

Date Extraction


c4rdinal

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/167222-date-extraction/
Share on other sites

$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));

Link to comment
https://forums.phpfreaks.com/topic/167222-date-extraction/#findComment-881798
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.