This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Phpr_DateTime class

Defined in /phproad/modules/phpr/classes/phpr_datetime.php, lines 12-792
Author LemonStand eCommerce Inc.
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 Description Defined By
addDays() adds the specified number of days to the object and returns the new date/time object. Phpr_DateTime
addHours() adds the specified number of hours to the object and returns the new date/time object. Phpr_DateTime
addMinutes() adds the specified number of minutes to the object and returns the new date/time object. Phpr_DateTime
addMonths() adds the specified number of months to the object and returns the new date/time object. Phpr_DateTime
addSeconds() adds the specified number of seconds to the object and returns the new date/time object. Phpr_DateTime
addYears() adds the specified number of years to the object and returns the new date/time object. Phpr_DateTime
compareDates() compares two date/time values. Phpr_DateTime
equals() determines whether a value of this object matches a value of another Phpr_DateTime object. Phpr_DateTime
format() returns a string representation of the date and time value. Phpr_DateTime
getDate() returns the date component of a date and time value represented by the object. Phpr_DateTime
getDay() returns the day component of the time represented by the object. Phpr_DateTime
getDayOfWeek() returns the day of the week as a decimal number [1,7], with 1 representing Monday. Phpr_DateTime
getDayOfYear() returns a zero-based day of the year for a date represented by the object. Phpr_DateTime
getHour() returns the hour component of the time represented by the object. Phpr_DateTime
getMinute() returns the minute component of the time represented by the object. Phpr_DateTime
getMonth() returns the month component of the time represented by the object. Phpr_DateTime
getSecond() returns the second component of the time represented by the object. Phpr_DateTime
getYear() returns the year component of the time represented by the object. Phpr_DateTime
parse() converts a string to a Phpr_DateTime object. Phpr_DateTime
toSqlDate() returns a string representing the date and time in SQL date format. Phpr_DateTime
toSqlDateTime() returns a string representing the date and time in SQL date/time format. Phpr_DateTime
__construct() creates a new class instance and sets its value to GMT date and time by default. Phpr_DateTime

Method details

addDays() method

public Phpr_DateTime addDays(integer $years)
$years integer specifies the number of days to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of days to the object and returns the new date/time object.

addHours() method

public Phpr_DateTime addHours(integer $years)
$years integer specifies the number of hours to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of hours to the object and returns the new date/time object.

addMinutes() method

public Phpr_DateTime addMinutes(integer $years)
$years integer specifies the number of minutes to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of minutes to the object and returns the new date/time object.

addMonths() method

public Phpr_DateTime addMonths(integer $years)
$years integer specifies the number of months to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of months to the object and returns the new date/time object.

addSeconds() method

public Phpr_DateTime addSeconds(integer $years)
$years integer specifies the number of seconds to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of seconds to the object and returns the new date/time object.

addYears() method

public Phpr_DateTime addYears(integer $years)
$years integer specifies the number of years to add.
{return} Phpr_DateTime returns the object object.
Adds the specified number of years to the object and returns the new date/time object.

compareDates() method

public static integer compareDates(DateTime $value_1, DateTime $value_2)
$value_1 DateTime specifies the first value to compare.
$value_2 DateTime specifies the second value to compare.
{return} integer returns the comparison result.
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() method

public boolean equals(Phpr_DateTime $value)
$value Phpr_DateTime specifies a value to compare with.
{return} boolean returns TRUE if the values match. Returns FALSE otherwise.
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() method

public string format(string $format)
$format string specifies the formatting string. For example: %F %X.
{return} string
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() method

public Phpr_DateTime getDate()
{return} Phpr_DateTime returns the date/time object with the time component truncated.
Returns the date component of a date and time value represented by the object.

getDay() method

public integer getDay()
{return} integer returns the day component.
Returns the day component of the time represented by the object.

getDayOfWeek() method

public integer getDayOfWeek()
{return} integer returns the day of week as integer value.
Returns the day of the week as a decimal number [1,7], with 1 representing Monday.

getDayOfYear() method

public integer getDayOfYear()
{return} integer returns the day of the year as an integer value.
Returns a zero-based day of the year for a date represented by the object.

getHour() method

public integer getHour()
{return} integer returns the hour component.
Returns the hour component of the time represented by the object.

getMinute() method

public integer getMinute()
{return} integer returns the minute component.
Returns the minute component of the time represented by the object.

getMonth() method

public integer getMonth()
{return} integer returns the month component.
Returns the month component of the time represented by the object.

getSecond() method

public integer getSecond()
{return} integer returns the second component.
Returns the second component of the time represented by the object.

getYear() method

public integer getYear()
{return} integer returns the year component.
Returns the year component of the time represented by the object.

parse() method

public static mixed parse(string $string, string $format=NULL, DateTimeZone $time_zone=NULL)
$string string specifies the string to parse. For example: %x %X.
$format string specifies the date/time format, compatible with PHP {http://php.net/manual/en/function.strftime.php strftime()} function format.
$time_zone DateTimeZone optional. Specifies a time zone to assign to the new object.
{return} mixed returns Phpr_DateTime object if the string was successfully parsed. Returns FALSE otherwise.
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() method

public Returns toSqlDate()
{return} Returns the date in format YYYY-MM-DD
Returns a string representing the date and time in SQL date format.

toSqlDateTime() method

public Returns toSqlDateTime()
{return} Returns the date in format YYYY-MM-DD HH:MM::SS
Returns a string representing the date and time in SQL date/time format.

__construct() method

public Phpr_DateTime __construct(string $date_time=NULL, DateTimeZone $time_zone=NULL)
$date_time string specifies the date and time in format '2006-01-01 10:00:00' to assign to the object. If this parameter is omitted, the current GMT time is used.
$time_zone DateTimeZone specifies the time zone to assign to the object. If this parameter is omitted, the GMT time zone is used.
{return} Phpr_DateTime returns new date/time object.
Creates a new class instance and sets its value to GMT date and time by default.