Frank Vèssia Posted November 25, 2011 Share Posted November 25, 2011 I have a publish date field in this format Y-m-d H:i:s Now i want to select pages published today (of course no matter the hour) I'm trying with $today = strtotime(date("Y-m-d")); $items = $pages->find("template=linkmain,publishdate*=$today,sort=-userid"); I get all pages as result, also pages with dirrefent day date...i tried also ^= with the same result... Link to comment Share on other sites More sharing options...
Soma Posted November 25, 2011 Share Posted November 25, 2011 I have a publish date field in this format Y-m-d H:i:s Now i want to select pages published today (of course no matter the hour) I'm trying with I get all pages as result, also pages with dirrefent day date...i tried also ^= with the same result... Dates are stored as timestamp not in the format you specify. It will be formated when output. So you would have to use a timestamp to use in the selector. For recieving page of today, you would have to create a start and end time range and use them in the selector. <?php $start = strtotime( date('Y-m-d') . " 00:00:00"); $end = strtotime( date('Y-m-d') . " 23:59:59"); $items = $pages->find("template=linkmain,publishdate>=$start,publishdate<=$end,sort=-userid"); haven't tested it but should work along these lines 2 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted November 25, 2011 Author Share Posted November 25, 2011 thanks Soma, it works.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now