Jump to content

[SOLVED] Quick Question about Dates / Time


JSHINER

Recommended Posts

Wondering how I can get a query to return results between two times.

 

For the times I have:

 

$timeNow = time();

$startDate = time($page['query']['$start_date']);

$endDate = time($page['query']['$end_date']);

 

I want it to return results where $startDate > $timeNow < $endDate

 

But my first problem is all of those are display the same time (current time) - and then, how do I setup a query to that effect.

Link to comment
https://forums.phpfreaks.com/topic/111686-solved-quick-question-about-dates-time/
Share on other sites

Did you solve this? If not, the field you are comparing obviously has to be in DATE/TIME format then you can compare as you would expect:

"SELECT * FROM Table WHERE aDate > NOW() AND aDate < '$endDate'"

 

$endDate has to be a string in a date/time format. I think that a bunch work; one is "mm/dd/yyyy" and I think "yyyy-mm-dd" works also, and both probably work with only digit years.

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.