Jump to content

[SOLVED] time()--how do i know if it is today?


chantown

Recommended Posts

Hi, I have a very simple question

 

I know that if you do time(), it will give u the timestamp right now.

 

Let's say people on my website makes a post, and i record that timestamp.

 

How do I determine if that timestamp is on today?

 

For example, i want it to show

 

Posted TODAY if it was really posted today, but say Posted DEC 5th, if it was not posted today.

 

:o ???

Link to comment
https://forums.phpfreaks.com/topic/81875-solved-time-how-do-i-know-if-it-is-today/
Share on other sites

Not sure if this is the simplest way...

 

$currentDate = date("F d y",time());
if ($currentDate == date("F d y", $userSubmittedTime)) {
  echo "Posted Today"
}

 

It formats the two dates into strings that show Month Day Year and compares them.

ex

December 15 2007

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.