tags:

views:

34

answers:

4

Does anyone know of a php class or library that helps deal with dates (meaning weekdays)? For example, I could use it to say "give me the timestamp for next Tuesday at 9:00" or "is this timestamp between next Tuesday and next Thursday".

I just have a part of my application that I need to make sure I'm not scheduling things at certain times.

A: 

Some of the comments in the PHP manual explain how to do this with date.

John at CashCommons
+4  A: 

There is the built-in DateTime class, but you don't even need it for this:

//this gives results in the default timezone
//timestamp for next Tuesday at 9:00
strtotime("next tuesday 09:00");
//is this timestamp between next Tuesday and next Thursday
$ts >= strtotime("next tuesday") && $ts < strtotime("next friday")
Artefacto
+2  A: 

If you must use a class Zend_Date is quite powerful. It comes with the Zend framework but is pretty standalone as far as I know. No obligation to implement MVC and all the other Zend stuff.

Iznogood
+3  A: 

Can you use strtotime()?

http://php.net/strtotime

Bart