I have developed this gist to make easy your tasks when you need to work on times function in php
Last active
April 29, 2016 00:01
-
-
Save shavidzet/a4fc1d7db19afbdb72ece9bf9112f503 to your computer and use it in GitHub Desktop.
Set date limit for particular product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dateLimitReached($db_date, $secLimit) { | |
$format = 'Y-m-d H:i:s'; | |
$current = date($format); | |
$limit = date( $format, strtotime("+$secLimit seconds", strtotime($db_date)) ); | |
$diff = strtotime($current) - strtotime($limit); | |
if ($diff < 0 && $diff >= -$secLimit) return true; | |
return false; | |
} | |
$db_date = '2016-04-28 11:18:00'; // date from this time | |
$diff = dateLimitReached($db_date, 60); // function return false if expires available date | |
var_dump($diff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment