WooCommerce Code Reference

WC_DateTime extends DateTime
in package

Datetime class.

Table of Contents

$utc_offset  : int
UTC Offset, if needed. Only used when a timezone is not set. When timezones are used this will equal 0.
__toString()  : string
Output an ISO 8601 date string in local (WordPress) timezone.
date()  : string
Format a date based on the offset timestamp.
date_i18n()  : string
Return a localised date based on offset timestamp. Wrapper for date_i18n function.
getOffset()  : mixed
Get UTC offset if set, or default to the DateTime object's offset.
getOffsetTimestamp()  : int
Get the timestamp with the WordPress timezone offset added or subtracted.
getTimestamp()  : int
Missing in PHP 5.2 so just here so it can be supported consistently.
set_utc_offset()  : mixed
Set UTC offset - this is a fixed offset instead of a timezone.
setTimezone()  : DateTime
Set timezone.

Properties

$utc_offset

UTC Offset, if needed. Only used when a timezone is not set. When timezones are used this will equal 0.

protected int $utc_offset = 0

Methods

__toString()

Output an ISO 8601 date string in local (WordPress) timezone.

public __toString() : string
Tags
since
3.0.0
Return values
string

date()

Format a date based on the offset timestamp.

public date(string $format) : string
Parameters
$format : string

Date format.

Tags
since
3.0.0
Return values
string

date_i18n()

Return a localised date based on offset timestamp. Wrapper for date_i18n function.

public date_i18n([string $format = 'Y-m-d' ]) : string
Parameters
$format : string = 'Y-m-d'

Date format.

Tags
since
3.0.0
Return values
string

getOffset()

Get UTC offset if set, or default to the DateTime object's offset.

public getOffset() : mixed
Return values
mixed

getOffsetTimestamp()

Get the timestamp with the WordPress timezone offset added or subtracted.

public getOffsetTimestamp() : int
Tags
since
3.0.0
Return values
int

getTimestamp()

Missing in PHP 5.2 so just here so it can be supported consistently.

public getTimestamp() : int
Tags
since
3.0.0
Return values
int

set_utc_offset()

Set UTC offset - this is a fixed offset instead of a timezone.

public set_utc_offset(int $offset) : mixed
Parameters
$offset : int

Offset.

Return values
mixed

setTimezone()

Set timezone.

public setTimezone(DateTimeZone $timezone) : DateTime
Parameters
$timezone : DateTimeZone

DateTimeZone instance.

Return values
DateTime