Jelix 1.7.18

jDateTime
in package

Utility to manipulate dates and convert date format.

Tags
subpackage

utils

Table of Contents

DB_DFORMAT  = 20
DB_DTFORMAT  = 21
DB_TFORMAT  = 22
FULL_LANG_DATE  = 62
ISO8601_FORMAT  = 40
LANG_DFORMAT  = 10
LANG_DTFORMAT  = 11
LANG_SHORT_DTFORMAT  = 13
LANG_SHORT_TFORMAT  = 14
LANG_TFORMAT  = 12
RFC2822_FORMAT  = 61
RFC822_FORMAT  = 60
TIMESTAMP_FORMAT  = 50
$day  : mixed
$defaultFormat  : mixed
$hour  : mixed
$minute  : mixed
$month  : mixed
$second  : mixed
$year  : mixed
__construct()  : mixed
add()  : mixed
Add a duration to the date.
compareTo()  : int
Compare two date.
durationTo()  : jDuration
to know the duration between two dates.
isNull()  : bool
Check if jDateTime is "null" (all values egals to 0).
now()  : mixed
Set date to current datetime.
setFromString()  : bool
read a string to extract date values.
sub()  : mixed
substract a <b>duration</b> to the date You can specify the duration in a jDuration object or give each value of the duration.
substract()  : jDateTime
Substract a date with another.
toString()  : string
Convert the date to a string format.
_check()  : bool
Checks if the current jDateTime object is a valid gregorian date/time.
_createDateFromFormat()  : bool
Create a date from a Date string format.

Constants

Properties

Methods

__construct()

public __construct(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second) : mixed
Parameters
$year : mixed
$month : mixed
$day : mixed
$hour : mixed
$minute : mixed
$second : mixed
Return values
mixed

add()

Add a duration to the date.

public add(int|jDuration $year, int $month, int $day, int $hour, int $minute, int $second) : mixed

You can specify the duration in a jDuration object or give each value of the duration.

Parameters
$year : int|jDuration

the duration value or a year with 4 digits

$month : int

month with 2 digits

$day : int

day with 2 digits

$hour : int

hour with 2 digits

$minute : int

minute with 2 digits

$second : int

second with 2 digits

Return values
mixed

compareTo()

Compare two date.

public compareTo(jDateTime $dt) : int
Parameters
$dt : jDateTime

the date to compare

Return values
int

-1 if $dt > $this, 0 if $dt = $this, 1 if $dt < $this

durationTo()

to know the duration between two dates.

public durationTo(jDateTime $dt[, bool $absolute = true ]) : jDuration
Parameters
$dt : jDateTime

the date on which a sub will be made with the date on the current object

$absolute : bool = true
Return values
jDuration

a jDuration object

isNull()

Check if jDateTime is "null" (all values egals to 0).

public isNull() : bool
Tags
author

Hadrien Lanneau

Return values
bool

now()

Set date to current datetime.

public now() : mixed
Return values
mixed

setFromString()

read a string to extract date values.

public setFromString(string $str[, int $format = -1 ]) : bool
Parameters
$str : string

the string date

$format : int = -1

one of the class constant xxx_FORMAT, or -1 if it should use the default format

Tags
see
jDateTime::$defaultFormat
Return values
bool

true if the format of $str has been parsed well

sub()

substract a <b>duration</b> to the date You can specify the duration in a jDuration object or give each value of the duration.

public sub(int|jDuration $year, int $month, int $day, int $hour, int $minute, int $second) : mixed
Parameters
$year : int|jDuration

the duration value or a year with 4 digits

$month : int

month with 2 digits

$day : int

day with 2 digits

$hour : int

hour with 2 digits

$minute : int

minute with 2 digits

$second : int

second with 2 digits

Return values
mixed

toString()

Convert the date to a string format.

public toString([int $format = -1 ]) : string
Parameters
$format : int = -1

one of the class constant xxx_FORMAT, or -1 if it should use the default format

Tags
see
jDateTime::$defaultFormat
Return values
string

the string date

_check()

Checks if the current jDateTime object is a valid gregorian date/time.

private _check() : bool
Return values
bool

true if the date/time are valid

_createDateFromFormat()

Create a date from a Date string format.

private _createDateFromFormat(string $lf, string $str) : bool
Parameters
$lf : string

Date string format

$str : string

The timestamp to parse

Tags
see
http://php.net/manual/fr/function.date.php
Return values
bool

false if the string $str has a bad format

Search results