|
Phpr_DateTime class
Represents a date and time value.
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 methods for returning formatted date and time value as string.
Public methods
Method details¶ addDays() methodpublic Phpr_DateTime addDays(integer $years)
Adds the specified number of days to the object and returns the new date/time object.
¶ addHours() methodpublic Phpr_DateTime addHours(integer $years)
Adds the specified number of hours to the object and returns the new date/time object.
¶ addMinutes() methodpublic Phpr_DateTime addMinutes(integer $years)
Adds the specified number of minutes to the object and returns the new date/time object.
¶ addMonths() methodpublic Phpr_DateTime addMonths(integer $years)
Adds the specified number of months to the object and returns the new date/time object.
¶ addSeconds() methodpublic Phpr_DateTime addSeconds(integer $years)
Adds the specified number of seconds to the object and returns the new date/time object.
¶ addYears() methodpublic Phpr_DateTime addYears(integer $years)
Adds the specified number of years to the object and returns the new date/time object.
¶ compareDates() methodpublic static integer compareDates(DateTime $value_1, DateTime $value_2)
Compares two date/time values.
Returns 1 if the first value is more than the second value,
0 if values are equal and
-1 if the first value is less than the second value.
This method takes into account the time zones of the date /ime objects.
¶ equals() methodpublic boolean equals(Phpr_DateTime $value)
Determines whether a value of this object matches a value of another Phpr_DateTime object.
This method takes into account the time zones of the date/time objects.
¶ format() methodpublic string format(string $format)
Returns a string representation of the date and time value.
The returned value can depend on the user language date/time format specified in
the LANGUAGE parameter in the configuration file.
The format specifiers are compatible with PHP strftime()
function.
Please note that in most cases date/time values are stored in the database in GMT timezone.
To convert date/time values to a time zone specified in the configuration file and display this value, 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'); ¶ getDate() methodpublic Phpr_DateTime getDate()
Returns the date component of a date and time value represented by the object.
¶ getDay() methodpublic integer getDay()
Returns the day component of the time represented by the object.
¶ getDayOfWeek() methodpublic integer getDayOfWeek()
Returns the day of the week as a decimal number [1,7], with 1 representing Monday.
¶ getDayOfYear() methodpublic integer getDayOfYear()
Returns a zero-based day of the year for a date represented by the object.
¶ getHour() methodpublic integer getHour()
Returns the hour component of the time represented by the object.
¶ getMinute() methodpublic integer getMinute()
Returns the minute component of the time represented by the object.
¶ getMonth() methodpublic integer getMonth()
Returns the month component of the time represented by the object.
¶ getSecond() methodpublic integer getSecond()
Returns the second component of the time represented by the object.
¶ getYear() methodpublic integer getYear()
Returns the year component of the time represented by the object.
¶ parse() methodpublic static mixed parse(string $string, string $format=NULL, DateTimeZone $time_zone=NULL)
Converts a string to a Phpr_DateTime object.
If the specified string can not be converted to a date/time value, returns boolean FALSE.
¶ toSqlDate() methodpublic Returns toSqlDate()
Returns a string representing the date and time in SQL date format.
¶ toSqlDateTime() methodpublic Returns toSqlDateTime()
Returns a string representing the date and time in SQL date/time format.
¶ __construct() methodpublic Phpr_DateTime __construct(string $date_time=NULL, DateTimeZone $time_zone=NULL)
Creates a new class instance and sets its value to GMT date and time by default.
|