Joseph Thomas Mallinson Joseph Thomas Mallinson - 1 year ago 84
PHP Question

php mysqli statement with time

I have the statement below that changes what is displayed depending on what time/day it is.

<?php $new = $mysqli->query("SELECT latedate FROM skiptonevents WHERE status='Active' ORDER BY id DESC LIMIT 1");
while($row = $new->fetch_assoc()) {
if($late < $datetime){
else {

In my database I have a column called latedate (0000-00-00 00:00:00).

$datetime = date('Y/m/d H:i:s');

I am trying to make it show (skiptonone.php) if todays date ($datetime) is less than latedate in the database ($late).

If latedate is after todays date to show skiptontwo.php

Could you please point me in the right direction as my current code does not work properly. It only shows skiptonone.php at the moment regardless of what time is in latedate.

Answer Source


if($late < $datetime){


if(strtotime($late) < time()){

This is because you're doing string comparison otherway.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download