Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.