php - Check if current time is within range of specified time -
i need able check if time within 15 minutes of specified time on days.
but issue is comparing minute , not days or years or months.
edit: have updated code still not work previous days.
$notification_time = strtotime("-1 hour", $cal_time); $really_now = time(); if($really_now >= strtotime("-15 minutes", $notification_time) && $really_now <= strtotime("+15 minutes", $notification_time)) { echo 'within time!'; } the above code works if $really_now within 30 minutes of -1 hour of $cal_time. when try:
$notification_time = strtotime("-1 day", $cal_time); if current time within 30 minutes of $cal_time -1 day not work.
<?php $cur_time = time(); $from_time = strtotime("-1 hour", $cur_time); echo round(abs($cur_time - $from_time) / 60,2). " minute"; ?> this provide difference in minutes. please note answered in post:
Comments
Post a Comment