Jump to content

Datetime selector problem


Harmster
 Share

Recommended Posts

Hey,

I need to select some pages that have a datetime between 2 user input datetimes. Now I use the datetime from pw and in the selector i try to select it with

$r = $pages->find("template=transaction, datetime>=$start_date, datetime<=$end_date);

Now my $start_date and $end_date are formatted by 31-12-2012 but also tried 2012-12-31

And when i try to select a page with a datetime of 03-12-2012 with <=04-12-2012 i get nothing and if 07-12-2012 i get all the pages...

What am I doing wrong?

Thanks in advance, sorry for the weird explaination, its friday.

So i figured out what the problem was, it was something in the code later on... I am stupid D:

Link to comment
Share on other sites

Dates are stored as unix-timestampes in the Database. ProcessWire does format them in templates when outputFormating is on.

Try this:

$s = strtotime($start_date);
$e = strtotime($end_date);
$r = $pages->find("template=transaction, datetime>=$s, datetime<=$e);
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...