Jump to content

Recommended Posts

Posted

Hi guys,

Any ideas on how to get all pages of a certain template that have been created this month?

I have tried to test for "created" within the selector and combining it with date("m") but I'm not sure how to go about this?

My goal is to set invoice numbers combing an autoincrementing value with each invoice that is created within a given month.

Any ideas? 

Thanks :)

Posted

Will this work?

$pages->find("template=certain, created>=$firstdayofthismonth, created<=$lastdayofthismonth, sort-=created");
  • Like 1
Posted

I think 

$pages->find("template=invoice,created>".strtotime("1 ".date("M")))

should find invoices created this month. You'd need some extra logic for past months, but strtotime is the key.

  • Like 2
  • 5 years later...
Posted

2018 update:

You can also use strtotime in selectors since a while (don't know in wich PW version, but it works in versions > 3. So you could do:

$pages->find('template=invoice,created>"first day of this month",created<"last day of this month"'))

 

  • Like 4
  • Thanks 1
Posted
1 hour ago, jmartsch said:

You can also use strtotime in selectors since a while

Woah! 

I knew that today will work but... woah!

That makes dev-life a lot easier.

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
×
×
  • Create New...