Documentation

DateTimeTrait

Pop utils date-time format helper trait

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
2.1.0

Table of Contents

Properties

$dateTimeFormat  : string|null
Date-time format
$dateTimeFormats  : array<string|int, mixed>
Date-time formats

Methods

detectDateTimeFormat()  : string|null
Detect date-time format
detectFormat()  : string|null
Detect date-time format

Properties

$dateTimeFormat

Date-time format

protected string|null $dateTimeFormat = null

$dateTimeFormats

Date-time formats

protected array<string|int, mixed> $dateTimeFormats = ['/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}$/' => 'Y-m-d H:i:s.v', '/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/' => 'Y-m-d H:i:s', '/^\\d{2}\\/\\d{2}\\/\\d{4} \\d{1,2}:\\d{2}\\s(A|P)M$/' => 'm/d/Y g:i A', '/^\\d{2}\\/\\d{2}\\/\\d{2} \\d{1,2}:\\d{2}\\s(A|P)M$/' => 'm/d/y g:i A', '/^\\d{4}-\\d{2}-\\d{2}$/' => 'Y-m-d', '/^\\d{2}\\/\\d{2}\\/\\d{4}$/' => 'm/d/Y', '/^\\d{2}\\.\\d{2}\\.\\d{4}$/' => 'd.m.Y', '/^\\d{2}\\/\\d{2}\\/\\d{2}$/' => 'm/d/y', '/^\\d{2}\\.\\d{2}\\.\\d{2}$/' => 'd.m.y', '/^\\d{2}:\\d{2}:\\d{2}$/' => 'H:i:s', '/^\\d{1,2}:\\d{2}\\s(A|P)M$/' => 'g:i A']

Methods

detectDateTimeFormat()

Detect date-time format

public static detectDateTimeFormat(string $dateTime) : string|null
Parameters
$dateTime : string
Return values
string|null

detectFormat()

Detect date-time format

public detectFormat(string $dateTime) : string|null
Parameters
$dateTime : string
Return values
string|null

        
On this page

Search results