WooCommerce Code Reference

Search results

WC_DateTime extends DateTime

Datetime class.

Table of Contents

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

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 = ""

Methods

__toString()

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

public __toString( ) : string
Tags
since
Return values
string

set_utc_offset()

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

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

Offset.

Return values
mixed

getOffset()

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

public getOffset( ) : mixed
Return values
mixed

setTimezone()

Set timezone.

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

DateTimeZone instance.

Return values
DateTime

getTimestamp()

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

public getTimestamp( ) : int
Tags
since
Return values
int

getOffsetTimestamp()

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

public getOffsetTimestamp( ) : int
Tags
since
Return values
int

date()

Format a date based on the offset timestamp.

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

Date format.

Tags
since
Return values
string

date_i18n()

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

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

Date format.

Tags
since
Return values
string
Back to the top