PHPLover
PHPLover

Reputation: 12957

How to compare a date with UNIX timestamp value in php?

I'm having a table(in MySQL) in which all dates are stored in the form of UNIX timestamp values. Now what I want to achieve is fetch up only those records from the table whose date will be today's date. How should I achieve this? Is any one have any magic for it? Please help me out to resolve this issue. Thanks in advance.

Upvotes: 0

Views: 2095

Answers (2)

xiaolee
xiaolee

Reputation: 26

you can get it like this.

eg.

ctime BETWEEN UNIX_TIMESTAMP(CURDATE()) and UNIX_TIMESTAMP(DATE_ADD(CURDATE(),INTERVAL 1 day))

Upvotes: 1

mirkobrankovic
mirkobrankovic

Reputation: 2347

DATE_FORMAT(FROM_UNIXTIME('date_before_format'), '%e %b %Y') AS 'date_formatted'

Upvotes: 0

Related Questions