I need to test current time against a datetime from database, if it has been 30 mins then execute code, if not then dont. This is where I am at and I am stuck:
$link = mysqli_connect("hostname", "username", "password", "database"); $q = "SELECT id FROM dwCache ORDER BY id DESC LIMIT 1"; $qu = mysqli_query($link, $q); while($row=mysqli_fetch_array($qu, MYSQL_ASSOC)){ $id = $row['id']; $cache = $row['cache']; $timest = $row['time']; } $newTime = $difference = $timest if($timest >= )
As you can see towards the bottom I lose it as I am not sure what to do.
$timest
returns : 2013-02-01 12:36:01
as the format Y-m-d
h-i-s
Apologies on double post, other deleted.
To perform assignments and comparisons between dates and timestamps or times and timestamps, you can use the SQL functions DATE, TIME, and TIMESTAMP, which convert values from one type to another. There might be situations when it is not practical for you to use these functions.
A date, time, or timestamp value can be compared with another value of the same data type, a datetime constant of the same data type, or with a string representation of a value of that data type. Additionally, a TIMESTAMP WITHOUT TIME ZONE value can be compared with a TIMESTAMP WITH TIME ZONE value.
Comparison between pandas timestamp objects is carried out using simple comparison operators: >, <,==,< = , >=. The difference can be calculated using a simple '–' operator. Given time can be converted to pandas timestamp using pandas. Timestamp() method.
First convert $timest
to timestamp
$time = strtotime($timest); $curtime = time(); if(($curtime-$time) > 1800) { //1800 seconds //do stuff }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With