jDateTime

Utility to manipulate dates and convert date format

package

jelix

subpackage

utils

Methods

__construct

__construct( $year,  $month,  $day,  $hour,  $minute,  $second) 

Arguments

$year

$month

$day

$hour

$minute

$second

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

_check() : boolean

Response

boolean

true if the date/time are valid.

Create a date from a Date string format

_createDateFromFormat(string $lf, \timestamp $str) : boolean
link

http://php.net/manual/fr/function.date.php

Arguments

$lf

string

Date string format

$str

\timestamp

The timestamp to parse

Response

boolean

false if the string $str has a bad format

Add a duration to the date.

add(\jDuration/int $year, integer $month, integer $day, integer $hour, integer $minute, integer $second) 

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

Arguments

$year

\jDuration/int

the duration value or a year with 4 digits

$month

integer

month with 2 digits

$day

integer

day with 2 digits

$hour

integer

hour with 2 digits

$minute

integer

minute with 2 digits

$second

integer

second with 2 digits

Compare two date

compareTo(\jDateTime $dt) : integer

Arguments

$dt

\jDateTime

the date to compare

Response

integer

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

to know the duration between two dates.

durationTo(\jDateTime $dt, boolean $absolute = true) : \jDuration

Arguments

$dt

\jDateTime

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

$absolute

boolean

Response

\jDuration

a jDuration object

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

isNull() : boolean
author

Hadrien Lanneau (hadrien at over-blog dot com)

Response

boolean

Set date to current datetime

now() 

read a string to extract date values

setFromString(string $str, integer $format = -1) : boolean
see \jDateTime:$defaultFormat

Arguments

$str

string

the string date

$format

integer

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

Response

boolean

true if the format of $str has been parsed well

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

sub(\jDuration/int $year, integer $month, integer $day, integer $hour, integer $minute, integer $second) 

Arguments

$year

\jDuration/int

the duration value or a year with 4 digits

$month

integer

month with 2 digits

$day

integer

day with 2 digits

$hour

integer

hour with 2 digits

$minute

integer

minute with 2 digits

$second

integer

second with 2 digits

Substract a date with another

substract(\jDateTime $date = null) : \jDateTime
author

Hadrien Lanneau hadrien@over-blog.com

since 1.2

Arguments

$date

\jDateTime

Response

\jDateTime

Convert the date to a string format

toString(integer $format = -1) : string
see \jDateTime:$defaultFormat

Arguments

$format

integer

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

Response

string

the string date

Constants

LANG_DFORMAT

LANG_DFORMAT

LANG_DTFORMAT

LANG_DTFORMAT

LANG_TFORMAT

LANG_TFORMAT

LANG_SHORT_DTFORMAT

LANG_SHORT_DTFORMAT

LANG_SHORT_TFORMAT

LANG_SHORT_TFORMAT

DB_DFORMAT

DB_DFORMAT

DB_DTFORMAT

DB_DTFORMAT

DB_TFORMAT

DB_TFORMAT

ISO8601_FORMAT

ISO8601_FORMAT

TIMESTAMP_FORMAT

TIMESTAMP_FORMAT

RFC822_FORMAT

RFC822_FORMAT

RFC2822_FORMAT

RFC2822_FORMAT

FULL_LANG_DATE

FULL_LANG_DATE

Properties

day

day : 

Type(s)

month

month : 

Type(s)

year

year : 

Type(s)

hour

hour : 

Type(s)

minute

minute : 

Type(s)

second

second : 

Type(s)

defaultFormat

defaultFormat : 

Type(s)