Home Contents | # clock.currentDate | Date/Time | Core4 Lua Commands

## SYNOPSIS

1. date = clock.currentDate()
2. date = clock.newDate(year, month, day)
3. date = clock.newDate(str)

## DESCRIPTION

Both functions create a new date instance. clock.currentDate() initializes the instance from the current system date, while clock.newDate() initializes from an arbitrary value.

Particularly, the third form takes a string str encoded in ISO8601 format "YYYY-MM-DD". This is the same format as returned by tostring(date).

## RETURN VALUE

Returns a new date instance.

## NOTES

The system clock runs in the UTC date zone. If you need the local date, please use clock.newDateTime() and convert to local date using datetime:toLocal().

## EXAMPLE

> >
d = clock.newDate(1989,11,9) print (d)
1989-11-09
> >
d = clock.newDate("1989-11-09") print(d:year(), d:month(), d:day())
1989 11 9

## SEE ALSO

date(), date:addDays, date:addMonths, date:addYears, date:day, date:dayOfWeek, date:dayOfYear, date:days90, date:daysInMonth, date:daysInYear, date:daysTo, date:format, date:isNull, date:isValid, date:month, date:set, date:setDays90, date:weekNumber, date:year, tostring(date)