Edit in GitHubLog an issue

require('uxp').xmp.XMPDateTime

Since: v7.2.0

XMPDateTime()

XMPDateTime class represents a date and time. XMP's time includes time zone, and can have up to nanosecond resolution.

XMPDateTime(date)

Create XMPDateTime

ParamTypeDescription
date
Date | string
[Optional] Date : A JavaScript Date object. The time zone is set to the local operation-system time-zone value. Time can have up to nanosecond resolution; however, when converting to or from a JavaScript Date value, time resolution is reduced to milliseconds.
iso8601Date: A string containing a date-time in ISO 8601 format; for example: "2007-04-10T17:54:50+01:00"

Example

Copied to your clipboard
1// Below example demonstrates how to create XMPDateTime
2// Importing XMPDateTime class
3const { XMPDateTime } = require("uxp").xmp;
4
5// 1. Creating using Date object
6const xdt1 = new XMPDateTime(new Date());
7
8// 2. Creating using iso8601Date
9const xdt2 = new XMPDateTime("2007-04-10T17:54:50+01:00");
10
11// 3. Creating with no arguments
12const xdt3 = new XMPDateTime();

Example

Copied to your clipboard
1// Below example demonstrates how to compare two XMPDateTime objects
2// Importing XMPDateTime class
3const { XMPDateTime } = require("uxp").xmp;
4
5const currentDate = new XMPDateTime(new Date());
6
7const oldDate = new XMPDateTime("2007-04-10T17:54:50+01:00");
8
9currentDate.compareTo(oldDate);
10// Returns 1
11
12oldDate.compareTo(currentDate);
13// Returns -1
14
15currentDate.compareTo(currentDate);
16// Returns 0

year : number

The year, in the range [0000…9999].

month : number

The month, in the range [1…12].

day : number

The day, in the range [1…31].

hour : number

The hour, in the range [1…23].

minute : number

The minute, in the range [1…59].

second : number

The second, in the range [1…59].

nanosecond : number

The nanosecond, in the range [0…1e+9 -1].

tzSign : number

The time zone direction of offset. - 0: UTC - -1: west - 1: east

tzHour : number

The time zone hour offset from the prime meridian, in the range [1…23].

tzMinute : number

The time zone minute offset from the prime meridian, in the range [1…59].

compareTo(dateTime)

Reports the time order of two date-time values.

Returns: number - 0 if the two values are the same,
1 if this date-time is later than the comparison value,
-1 if this date-time is earlier than the comparison value.
number

ParamTypeDescription
dateTime
XMPDateTime
Another XMPDateTime object.

convertToLocalTime()

Sets the time zone in this object to the local operating-system time zone, adjusting the time values from the previous time zone, if necessary.

convertToUTCTime()

Sets the time zone in this object to UTC (coordinated universal time), adjusting the time values from the previous time zone, if necessary.

getDate()

Converts this date-time value to a JavaScript Date. The time zone is normalized (time zones are not supported in the JavaScript format), and the accuracy is reduced to milliseconds.

Returns: Date

setLocalTimeZone()

Sets the time zone in this object to the current operation-system value, replacing any existing value. Does not affect other fields.

hasDate()

To check if the date is available

Returns: boolean

hasTime()

To check if time is available

Returns: boolean

hasTimeZone()

To check if timezone is available

Returns: boolean

toString()

To get the string value of the object

Returns: string

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.