# date date and time library ## Function date() creates a local time zone Date object; supports date string parsing, chrono/strftime style formatting, Unix timestamp conversion, date operations, and reading of fields such as year, month, day, hour, minute, and second. ## Syntax ```bt date() date(timestamp) date(text) ``` ## Parameters | Parameter | Type | Required | Default value | Description | | ------ | ------ | ------ | ------ | ------ | | timestamp | Int/Float | No | None | Second level Unix timestamp; if no parameters are passed, the current local time is returned. | | text | String | No | None | Date string or second-level Unix timestamp string. | ## Return Value | Type | Description | | ------ | ------ | | Date | Returns the local time zone Date object. | ## API List | API | Description | | ------ | ------ | | [Date.format](/en/docs/date/format) | Output date and time according to format string. | | [Date.from_string](/en/docs/date/from_string) | Parses a date string and creates a new Date object. | | [Date.from_timestamp](/en/docs/date/from_timestamp) | Creates a new Date object from a Unix timestamp in seconds. | | [Date.from_millis](/en/docs/date/from_millis) | Create a new Date object from a millisecond Unix timestamp. | | [Date.from_micros](/en/docs/date/from_micros) | Creates a new Date object from a microsecond Unix timestamp. | | [Date.from_nanos](/en/docs/date/from_nanos) | Creates a new Date object from a nanosecond Unix timestamp. | | [Date.add](/en/docs/date/add) | Returns a new Date object plus or minus the specified time. | | [Date.diff](/en/docs/date/diff) | Returns the difference between two dates converted in the specified unit. | | [Date.start_of_day](/en/docs/date/start_of_day) | Returns a new Date object at zero o'clock on the day. | | [Date.timestamp](/en/docs/date/timestamp) | Read second-level Unix timestamp. | | [Date.timestamp_millis](/en/docs/date/timestamp_millis) | Read millisecond-level Unix timestamp. | | [Date.timestamp_micros](/en/docs/date/timestamp_micros) | Read microsecond-level Unix timestamp. | | [Date.timestamp_nanos](/en/docs/date/timestamp_nanos) | Read a nanosecond Unix timestamp. | | [Date.year](/en/docs/date/year) | Read the year. | | [Date.month](/en/docs/date/month) | Read the month. | | [Date.day](/en/docs/date/day) | Read the day of the month. | | [Date.hour](/en/docs/date/hour) | Read the hour. | | [Date.minute](/en/docs/date/minute) | Read minutes. | | [Date.second](/en/docs/date/second) | Read seconds. | | [Date.millis](/en/docs/date/millis) | Read the millisecond part of the current second. | | [Date.micros](/en/docs/date/micros) | Read the microsecond part of the current second. | | [Date.nanos](/en/docs/date/nanos) | Read the nanosecond part of the current second. | | [Date.weekday](/en/docs/date/weekday) | Read the weekday number. | | [Date.week](/en/docs/date/week) | Read the ISO week number. | | [Date.yearday](/en/docs/date/yearday) | Read the date serial number in a year. | | [Date.quarter](/en/docs/date/quarter) | Read quarter. | | [Date.to_string](/en/docs/date/to_string) | Output the date and time in the default format. | ## Code Examples ```bt // Output: 2026-06-09 10:11 print date().format('%Y-%m-%d %H:%M') d = date('2026-06-09 10:11:12') result = { text: d.format('%Y-%m-%d'), timestamp: d.timestamp(), quarter: d.quarter() } ``` ## Notes - No parameters date() returns the current local time. - Integer and floating point arguments create a Date in seconds Unix timestamp. - String parameters will be parsed into Date according to common date formats, and date('%Y-%m-%d') is no longer supported to directly format the current time. - To format the current time, use date().format('%Y-%m-%d'). - Date uses the local time zone internally and uses the first local time result when daylight saving time ambiguities are encountered.