Bixby Developer Center

References

dates

Caution

The dates module is not available with JavaScript Runtime System Version 2. Read Replacing the dates Module for guidance.

Importing with JavaScript Runtime Version 1:

var dates = require('dates')

The following sections describe the available methods within this module. Each section includes a table that lists the parameters for that method, as well as the parameter's type and description.

dates.durationFromMilliseconds(milliseconds)

Convert a duration (milliseconds) to a DurationPeriod (structure)

Kind: Static method of dates
Returns: DurationPeriod - Object with properties

  • periodDays
  • periodHours
  • periodMinutes
  • periodSeconds
  • periodMilliseconds
ParameterTypeDescription
millisecondsZonedDateTimeMilliseconds since the beginning of the epoch

dates~ZonedDateTime

Kind: Inner class of dates
Access: Public

new ZonedDateTime(timeZoneIdOrGeoPoint, [millisecondsFromEpoch])

Returns: ZonedDateTime - Immutable object containing a representation of a date-time with a timezone. Use instead of the built-in Date object.

ParameterTypeDefaultDescription
timeZoneIdOrGeoPointStringObject
[ millisecondsFromEpoch ]IntegernowThe number of milliseconds since the start of the UNIX epoch, January 1 1970 at 00:00:00 UTC

ZonedDateTime.getMillisFromEpoch()

Kind: Instance method of ZonedDateTime
Returns: Integer - Milliseconds from start of epoch of the specified dateTime.
Access: Public

ZonedDateTime.getTimeZoneId()

Kind: Instance method of ZonedDateTime
Returns: String - Timezone ID of the specified timezone
Access: Public

ZonedDateTime.getDateTime()

Kind: Instance method of ZonedDateTime
Returns: Object - DateTime object with date and time properties
Access: Public

ZonedDateTime.getDayOfWeek()

Kind: Instance method of ZonedDateTime
Returns: Integer - Named day of the week Access: Public

ZonedDateTime.getYear()

Kind: Instance method of ZonedDateTime
Returns: Integer - Year of the specified date
Access: Public

ZonedDateTime.getMonth()

Kind: Instance method of ZonedDateTime
Returns: Integer - Month of the specified date Access: Public

ZonedDateTime.getDay()

Kind: Instance method of ZonedDateTime
Returns: Integer - Day of the specified date
Access: Public

ZonedDateTime.getHour()

Kind: Instance method of ZonedDateTime
Returns: Integer - Hour of the specified time
Access: Public

ZonedDateTime.getMinute()

Kind: Instance method of ZonedDateTime
Returns: Integer - Minute of the specified time
Access: Public

ZonedDateTime.getSecond()

Kind: Instance method of ZonedDateTime
Returns: Integer - Second of the specified time
Access: Public

ZonedDateTime.getMillisecond()

Kind: Instance method of ZonedDateTime
Returns: Integer - Millisecond of the specified time
Access: Public

ZonedDateTime.getTimeZoneOffset()

Kind: Instance method of ZonedDateTime
Returns: Integer - Timezone offset, in seconds, of the specified timezone
Access: Public

ZonedDateTime.isDST()

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true if the specified timezone uses daylight savings time at the specified date and time, otherwise false
Access: Public

ZonedDateTime.withYear(year)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified year set
Access: Public

ParameterType
yearInteger

ZonedDateTime.withMonth(month)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified month set
Access: Public

ParameterType
monthInteger

ZonedDateTime.withDay(day)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified day set
Access: Public

ParameterType
dayInteger

ZonedDateTime.withHour(hour)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified hour set
Access: Public

ParameterType
hourInteger

ZonedDateTime.withMinute(minute)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified minute set
Access: Public

ParameterType
minuteInteger

ZonedDateTime.withSecond(second)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified second set
Access: Public

ParameterType
secondInteger

ZonedDateTime.withMillisecond(millisecond)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified millisecond set
Access: Public

ParameterType
millisecondInteger

ZonedDateTime.withZoneSameInstant(timeZoneId)

Construct a new ZonedDateTime for the same instant in time, but translated to a different timezone

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified time zone applied
Access: Public

ParameterType
timeZoneIdString

ZonedDateTime.withZoneSameLocal(timeZoneId)

Construct a new ZonedDateTime for the same local dateTime, but translated to a different timezone

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with specified time zone applied
Access: Public

ParameterType
timeZoneIdString

ZonedDateTime.plusYears(years)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by years
Access: Public

ParameterType
yearsInteger

ZonedDateTime.plusMonths(months)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by months
Access: Public

ParameterType
monthsInteger

ZonedDateTime.plusDays(days)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by days
Access: Public

ParameterType
daysInteger

ZonedDateTime.plusHours(hours)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by hours
Access: Public

ParameterType
hoursInteger

ZonedDateTime.plusMinutes(minutes)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by minutes
Access: Public

ParameterType
minutesInteger

ZonedDateTime.plusSeconds(seconds)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by seconds
Access: Public

ParameterType
secondsInteger

ZonedDateTime.plusMilliseconds(milliseconds)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by milliseconds
Access: Public

ParameterType
millisecondsInteger

ZonedDateTime.plusDuration(duration)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object incremented by the given duration
Access: Public

ParameterType
durationObject

ZonedDateTime.minusYears(years)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by years
Access: Public

ParameterType
yearsInteger

ZonedDateTime.minusMonths(months)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by months
Access: Public

ParameterType
monthsInteger

ZonedDateTime.minusDays(days)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by days
Access: Public

ParameterType
daysInteger

ZonedDateTime.minusHours(hours)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by hours
Access: Public

ParameterType
hoursInteger

ZonedDateTime.minusMinutes(minutes)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by minutes
Access: Public

ParameterType
minutesInteger

ZonedDateTime.minusSeconds(seconds)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by seconds
Access: Public

ParameterType
secondsInteger

ZonedDateTime.minusMilliseconds(milliseconds)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by milliseconds
Access: Public

ParameterType
millisecondsInteger

ZonedDateTime.minusDuration(duration)

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object decremented by the given duration
Access: Public

ParameterType
durationObject

ZonedDateTime.atStartOfDay()

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with time adjusted to the start of the current day

ZonedDateTime.atEndOfDay()

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with time adjusted to the end of the current day

ZonedDateTime.compareTo(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Integer - 0 when other is identical, -1 when other is later, 1 when other is earlier.

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare

ZonedDateTime.isEqualTo(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true when other is identical, false otherwise.

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare

ZonedDateTime.isBefore(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true when other is later, false otherwise

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare.

ZonedDateTime.isBeforeOrEqualTo(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true when other is later or identical, false otherwise.

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare.

ZonedDateTime.isAfter(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true when other is earlier, false otherwise

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare

ZonedDateTime.isAfterOrEqualTo(other)

Compares one ZonedDateTime to another. Comparison is based solely off of the instant in time, regardless of timezone.

Kind: Instance method of ZonedDateTime
Returns: Boolean - Returns true when other is earlier or identical, false otherwise.

ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare

ZonedDateTime.durationUntil(other, unit)

Get the duration from this ZonedDateTime to another

Kind: Instance method of ZonedDateTime
Returns: DurationPeriod - Object with property for unit (if provided), or properties

  • periodYears
  • periodMonths
  • periodDays
  • periodHours
  • periodMinutes
  • periodSeconds
  • periodMilliseconds
ParameterTypeDescription
otherZonedDateTimeThe ZonedDateTime to compare
unitStringThe unit to use (can be Years, Months, Days, Hours Minutes, Seconds, Millis)

ZonedDateTime.clone()

Kind: Instance method of ZonedDateTime
Returns: ZonedDateTime - New object with the same timezone and instant in time

ZonedDateTime.toIsoString()

Kind: Instance method of ZonedDateTime
Returns: String - The specified instant in time and timezone, formatted as an ISO 8601 combined date and time

ZonedDateTime.toString()

Kind: Instance method of ZonedDateTime
Returns: String - The specified instant in time and timezone, formatted using the default pattern, Java's DateTimeFormatter.ISO_ZONED_DATE_TIME.

ZonedDateTime.toJSON()

Kind: Instance method of ZonedDateTime
Returns: Object - The specified instant in time and timezone, returned as a JSON object.

{
"date": {
"year": integer,
"month": integer,
"day": integer
},
"time": {
"hour": integer,
"minute": integer,
"second": integer,
"millisecond": integer
}
}

ZonedDateTime.format([pattern], [locale])

Kind: Instance method of ZonedDateTime
Returns: String - The specified instant in time and timezone, formatted using the provided pattern.

If the pattern is null, will use Java's DateTimeFormatter.ISO_ZONED_DATE_TIME. An optional second argument can be provided to specify a locale; this is equivalent to Java's DateTimeFormatter.ofPattern(pattern, locale).

ParameterTypeDescription
[ pattern ]StringA pattern as specified by Java's DateTimeFormatter
[ locale ]StringA locale in language-country format (ko-KR, en-US, etc.)

ZonedDateTime.now()

Returns a new dates.ZonedDateTime set to the default user time and timezone, or optionally, the specified timezone.

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object using all available date-time params.

ParameterTypeDescription
[ timezone ]StringA timezone ID. If null, uses default timezone.

ZonedDateTime.of([timezone], [year], [month], [day], [hour], [minute], [second], [millisecond])

Returns a new dates.ZonedDateTime with the arguments provided. All arguments are optional. If the first argument is a string, it's assumed to be the timeZoneId. Otherwise, the default user time zone is used and all other inputs must be integer values (month and day are 1-based, others are 0-based). If no arguments are provided, then it's equivalent to calling dates.ZonedDateTime.now().

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object using all available date-time params.

ParameterTypeDefaultDescription
[ timezone ]StringA timezone ID. If null, uses default timezone.
[ year ]Integer0
[ month ]Integer1
[ day ]Integer1
[ hour ]Integer0
[ minute ]Integer0
[ second ]Integer0
[ millisecond ]Integer0 

ZonedDateTime.fromDate(date)

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object at the start of the specified date, in the default timezone

ParameterTypeDescription
dateDateAn object with properties for year, month, and day

ZonedDateTime.fromDateTime(dateTime)

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object at the start of the specified date and time, in the default timezone

ParameterTypeDescription
dateTimeDateTimeAn object with properties for date and time

ZonedDateTime.parseDate(input, [pattern], [timeZoneId], [locale])

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object at the beginning of the specified date, either in the specified timezone or in the default timezone.

An optional third argument can be provided to specify a locale; this is equivalent to Java's DateTimeFormatter.ofPattern(pattern, locale).

ParameterTypeDescription
inputStringThe string to parse
[ pattern ]StringA pattern as specified by Java's DateTimeFormatter
[ timeZoneId ]StringThe timezone ID
[ locale ]StringA locale in language-country format (ko-KR, en-US, etc.)

ZonedDateTime.parseTime(input, [pattern], [timeZoneId], [locale])

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object at the specified time of the current date, either in the specified timezone or in the default timezone.

An optional third argument can be provided to specify a locale; this is equivalent to Java's DateTimeFormatter.ofPattern(pattern, locale).

ParameterTypeDescription
inputStringThe string to parse.
[ pattern ]StringA pattern as specified by Java's DateTimeFormatter
[ timeZoneId ]StringThe timezone ID.
[ locale ]StringA locale in language-country format (ko-KR, en-US, etc.)

ZonedDateTime.parseDateTime(input, [pattern], [timeZoneId], [locale])

Kind: Static method of ZonedDateTime
Returns: ZonedDateTime - A new object at the specified date and time, either in the specified timezone or in the default timezone.

An optional third argument can be provided to specify a locale; this is equivalent to Java's DateTimeFormatter.ofPattern(pattern, locale).

ParameterTypeDescription
inputStringThe string to parse
[ pattern ]StringA pattern as specified by Java's DateTimeFormatter
[ timeZoneId ]StringThe timezone ID
[ locale ]StringA locale in language-country format (ko-KR, en-US, etc.)

~(param)

Kind: Inner method of dates. Convenience method for creating a new dates.ZonedDateTime for the current date-time. An optional timeZoneId or geoPoint can be provided, otherwise the default user time zone is used.
Returns: Object - Current date-time for the specified timezone or in the provided geo-point location.
Access: Public

ParameterTypeDescription
paramStringObject
dates