I will be getting a book report!allspiritseve wrote:I posted another thread about this, but I do remember PHP in action went pretty in-depth with date/time objects. I don't remember it that well, but I remember thinking it looked useful. I've ordered it through our inter-library loan, so I should have it in a couple of days.
Yes, the built-in DateTime class is pretty useful. I just extended it for simple things like _toString, fluent interface, and so you can do date comparisons like ($date1 > $date2). The only function I added is one that tries to sort out user entered dates in yyyy/mm/dd, dd/mm/yy, mm/dd/yy. styles with any delimiter and 2/4 digit years.allspiritseve wrote:Have you used the DateTime classes in any projects? Are they useful, or does better code need to be written?
For a timezone solution, could the interface be as easy as a TzToUtc() and UtcToTz() methods so you could go back and forth for stored values? How could it internally deal with the stuff pytrin mentions to "just work" ?
Code: Select all
class MyDateTime extends DateTime {
public function TzToUtc($tztime) {
// ...
return $utctime;
}
public function UtcToTz($utctime) {
// ...
return $tztime;
}
}