datetime

The primary DateTime class that represents a date and time object in BoxLang

All temporal methods in BoxLang operate on this class and all castable date/time representations are cast to this class

Datetime Methods

add(datepart=[string], number=[number])

Modifies a date object by date part and integer time unit

Arguments:

Argument
Type
Required
Default

datepart

string

true

null

number

number

true

null

clone()

compare(date2=[any], datepart=[string])

Compares the difference between two dates - returning 0 if equal, -1 if date2 is less than date1 and 1 if the inverse

Arguments:

Argument
Type
Required
Default

date2

any

true

null

datepart

string

false

null

compareTo(date2=[any], datepart=[string])

Compares the difference between two dates - returning 0 if equal, -1 if date2 is less than date1 and 1 if the inverse

Arguments:

Argument
Type
Required
Default

date2

any

true

null

datepart

string

false

null

dateFormat(mask=[string], timezone=[string], locale=[string])

Formats a datetime, date or time

Arguments:

Argument
Type
Required
Default

mask

string

false

null

timezone

string

false

null

locale

string

false

null

dateTimeFormat(mask=[string], timezone=[string], locale=[string])

Formats a datetime, date or time

Arguments:

Argument
Type
Required
Default

mask

string

false

null

timezone

string

false

null

locale

string

false

null

day(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

dayOfWeek(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

dayOfWeekAsString(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

dayOfWeekShortAsString(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

dayOfYear(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

daysInMonth(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

daysInYear(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

diff(datepart=[string], date2=[any])

Returns the numeric difference in the requested date part between two dates

Arguments:

Argument
Type
Required
Default

datepart

string

true

null

date2

any

true

null

duplicate(deep=[boolean])

Duplicates an object - either shallow or deep

Arguments:

Argument
Type
Required
Default

deep

boolean

false

true

equals(obj=[any])

Indicates whether some other object is "equal to" this one.

Arguments:

Argument
Type
Required
Default

obj

any

true

null

firstDayOfMonth(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

format(mask=[string], timezone=[string], locale=[string])

Formats a datetime, date or time

Arguments:

Argument
Type
Required
Default

mask

string

false

null

timezone

string

false

null

locale

string

false

null

getnumericdate(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

getTime(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

hash(algorithm=[string], encoding=[string], numIterations=[integer])

Creates an algorithmic hash of an object

Arguments:

Argument
Type
Required
Default

algorithm

string

false

MD5

encoding

string

false

utf-8

numIterations

integer

false

1

hour(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

len()

Returns the absolute value of a number

millisecond(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

minute(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

month(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

monthAsString(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

monthShortAsString(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

nanosecond(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

offset(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

quarter(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

second(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

timeFormat(mask=[string], timezone=[string], locale=[string])

Formats a datetime, date or time

Arguments:

Argument
Type
Required
Default

mask

string

false

null

timezone

string

false

null

locale

string

false

null

timezone(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

toEpoch()

Returns this date time in epoch time ( seconds )

toEpochMillis()

Returns this date time in epoch milliseconds

toEpochSecond()

toISOString()

Returns the date time representation as a string in the specified format mask

toODBCDate(timezone=[string])

Creates a DateTime object with the format set to ODBC Implicit format

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

toODBCDateTime(timezone=[string])

Creates a DateTime object with the format set to ODBC Implicit format

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

toODBCTime(timezone=[string])

Creates a DateTime object with the format set to ODBC Implicit format

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

week(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

year(timezone=[string], locale=[string])

Provides the BIF and member functions for all time unit request with no arguments

Arguments:

Argument
Type
Required
Default

timezone

string

false

null

locale

string

false

null

Examples

Last updated

Was this helpful?