For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

bxDump(label=[string], top=[numeric], expand=[boolean], abort=[boolean], output=[string], format=[string], showUDFs=[boolean])

Outputs the contents of a variable (simple or complex) of any type for debugging purposes to a specific output location.

, The available ,,output,, locations are: - ,,buffer,,: The output is written to the buffer, which is the default location. If running on a web server, the output is written to the browser. - ,,console,,: The output is printed to the System console. - ,,Absolute File Path,, The output is written to a file with the specified absolute file path. ,

,

The output format can be either HTML or plain text.

The default format is HTML if the output location is the buffer or a web server or a file, otherwise it is plain text for the console.

Arguments:

Argument
Type
Required
Default

label

string

false

null

top

numeric

false

null

expand

boolean

false

true

abort

boolean

false

false

output

string

false

null

format

string

false

null

showUDFs

boolean

false

true

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

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()

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

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?