Phpr_DateTime
The Phpr_DateTime class represents a date and time. Usually you don't need to create instances of this class manually. Some fields of LemonStand objects are instances of Phpr_DateTime class, for example the $order_datetime field of the Shop_Order class. The class has a method for returning a formatted date and time value as string.
Class methods
- format($format_string) – returns a value of the date and time represents by the object, as string. The $format_string parameter specifies a date/time format. The format string supports a number of specifiers, matching the specifiers of the PHP strftime function.
The date/time values are stored in the database in GMT time zone. To convert date/time values to a time zone specified in the configuration file and display this value, plese use the following code:
// Display the date and time when a product was added to the database echo Phpr_Date::display($product->created_at, '%x %X');The format string (the second parameter) matches the format string of the PHP strftime() function.
To calculate a difference between the current date and a date represented with a Phpr_DateTime object, use the following code:
// Display the number of days between the current date and the // date when a product was added to the database $interval = Phpr_DateTime::gmtNow()->substractDateTime($product->created_at); echo $interval->getDays();
Next: Phpr_Pagination
Previous: Db_File
Return to Reference


Comments
Peter Crouch
Thursday, March 31, 2011Dates not displaying correctly? Try fiddling with the $CONFIG['LANGUAGE'] setting in the config/config.php file. By setting mine to "au" the date is now being shown correctly for my region of the world.
Add your comment
Loading form...