add 6 months to date in php
$effectiveDate = date('Y-m-d', strtotime("+3 months", strtotime($effectiveDate)));
add 6 months to date in php
$effectiveDate = date('Y-m-d', strtotime("+3 months", strtotime($effectiveDate)));
12 months service expiary in php
<?php
// Careful! strtotime() will interpret 12/10/2020 as "10 December 2020", where you expect it to be 12 October 2020!
// Consider the code below for an alternative, more robust solution.
$today = new DateTime;
// Added time for uniformity.
// "Notice of default" used to indicate the final date for possible payment,
// before services are suspended and/or legal action is taken.
// use setDate() and setTime() to explicitly set the date/time, to avoid caveats with international date formats
// as pointed out above.
$noticeOfDefaultAt = (new DateTime)->setDate(2021, 2, 10)->setTime(7, 0);
// First reminder (yellow) sent 3 months before expiration date.
// DateInterval() accepts a formatted string which decodes here to:
// P = Period of
// 3 = 3
// M = Months
// Use sub() to get the period offset from the final payment date ($noticeOfDefault)
$firstReminderAt = (clone $noticeOfDefaultAt)->sub(new DateInterval('P3M'));
// Second reminder (orange) sent 1 month before expiration date.
$secondReminderAt = (clone $noticeOfDefaultAt)->sub(new DateInterval('P1M'));
// Default to transparent if within payment period.
$bgColor = 'transparent';
if ($today >= $firstReminderAt && $today < $secondReminderAt)
// Today is within grace period of first reminder.
$bgColor = 'yellow';
if ($today >= $secondReminderAt && $today < $noticeOfDefaultAt)
// Today is within grace period of second reminder.
$bgColor = 'orange';
if ($today >= $noticeOfDefaultAt)
// We have a really sh*tty customer. Send legal team.
$bgColor = 'red';
// Change the color names to any rgb-hex value you want and use them in your "style" attribute.
echo $bgColor;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us