Jump to content

[SOLVED] If today's date don't display date


Kemik

Recommended Posts

Hello all,

 

Can you check this code and tell me where I'm going wrong please?

 

<?php
if ($row->datetime == date("Y-m-d")) {
$datetime = date("H:i", strtotime($row->datetime));
} else {
$datetime = date("d/m H:i", strtotime($row->datetime));
}?>

 

I'm unsure how I would do the if part of the statement as the datetime is in SQL Datetime format. I know I need to say its strtotime but I'm not sure where to put it.

Link to comment
https://forums.phpfreaks.com/topic/69318-solved-if-todays-date-dont-display-date/
Share on other sites

I was just on the point of posting an identical solution.

 

Explanation : $row->datetime contains the time element whereas date('Y-m-d') has 0 time element (ie YYYY-MM-DD 00:00:00) so the two are not equal.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.