---
schema: rendered-html/v1
title: "date-time | Developer Portal for YouTrack and Hub Documentation"
source_url: https://www.jetbrains.com/help/youtrack/devportal/v1-date-time.html
generated_at: 2026-06-11T15:20:35.323082+00:00
---

Feedback

Thanks for your feedback!

Was this page helpful?

YesNo

Developer Portal for YouTrack and Hub

- Developer Portal
- Apps
- MCP Tools
- YouTrack Workflows
- JavaScript Workflow Quick Start Guide
- Create a Workflow
- Edit a Workflow
- Workflow Rule Types
- Transactions
- Use Cases for Workflows
- Web-based Workflow Editor
- Using an External Code Editor
- Default Workflows
- Custom Workflow Repository
- JavaScript Workflow Reference
- Rule-specific Properties
- Context
- Requirements
- Using the Workflow API
- Building Integrations with Slack
- Using REST API Methods in JavaScript Workflows
- Working with Dates and Times
- Working with Periods
- Localized Workflow Messages
- Troubleshooting Workflows
- Remote Debugger
- YouTrack Workflow API
- Change Log
- [date-time](v1-date-time.html)
- [entities](jetbrains__com__help__youtrack__devportal__v1-entities.md)
- http
- license
- notifications
- search
- strings
- workflow
- YouTrack Import Scripts
- YouTrack Form API
- YouTrack REST API
- Hub REST API

1. YouTrack Workflows
2. JavaScript Workflow Reference
3. YouTrack Workflow API
4. [date-time](#0)

# date-time﻿

Last modified: 13 May 2026

This module contains functions that let you work with dates and times.

## Functions﻿

### after﻿

```
static after(timestamp, duration)
```

Returns a timestamp that represents a point in time after the specified period from the specified date.

Available since 2018.2.42881

**Parameters**

| --- | --- | --- |
| timestamp | number, object, string | The base date value. |
| duration | number, string, Period | A duration as a number (in milliseconds), string representation, or period as retrieved from a custom field or returned by the toPeriod() function. The string representation is a series of numeric values followed by the abbreviation that represents the timespan, in descending order. For example, 3w4d23h58m. |

**Return Value**

| Type | Description |
| number | The resulting timestamp. |

### before﻿

```
static before(timestamp, duration)
```

Returns a timestamp that represents a point in time before the specified period from the specified date.

Available since 2018.2.42881

**Parameters**

| --- | --- | --- |
| timestamp | number, object, string | The base date value. |
| duration | number, string, Period | A duration as a number (in milliseconds), string representation, or period as retrieved from a custom field or returned by the toPeriod() function. The string representation is a series of numeric values followed by the abbreviation that represents the timespan, in descending order. For example, 3w4d23h58m. |

**Return Value**

| Type | Description |
| number | The resulting timestamp. |

### format﻿

```
static format(timestamp, format, timeZoneId)
```

Creates a string representation of a Unix timestamp.

**Parameters**

| --- | --- | --- |
| timestamp | number, object, string | The timestamp to format as a string. |
| format | string | The date format to apply to the output. If no value is specified, the date format is supplied by the system. For actions that are attributed to the current user, the date format setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global date fields format setting is applied. For example, use `yyyy-MM-dd HH:mm` to show the year, month, day, hour, and minute, or `yyyy-MM-dd'T'HH🇲🇲ss.SSSZ` to include seconds, milliseconds, and a time zone offset. For format description, see <https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html>. |
| timeZoneId | string | The ID of a time zone. Applies an offset to the original timestamp, which is in UTC. If no value is specified, the time zone is supplied by the system. For actions that are attributed to the current user, the local time zone setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global default time zone is applied. For a list of time zone IDs, see [JodaTime](http://joda-time.sourceforge.net/timezones.html). |

**Return Value**

| Type | Description |
| string | A string representation of the specified timestamp. |

### parse﻿

```
static parse(dateTimeString, formats, timeZoneId)
```

Parses a string representation of a date to return a Unix timestamp. Use this method instead of the Date.parse() method from JavaScript. For a detailed explanation, refer to the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).

**Parameters**

| --- | --- | --- |
| dateTimeString | string | The string representation of a date. |
| formats | string, Array.<string> | A date format that possibly matches the dateTimeString or an array of formats. If an array is provided, the formats are applied sequentially until the dateTimeString is parsed successfully. If no value is specified, the date format is supplied by the system. For actions that are attributed to the current user, the date format setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global date fields format setting is applied. For format description, see <https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html>. |
| timeZoneId | string | The ID of a time zone in which the dateTimeString occurs. This parameter is only effective when the format that matches the string does not provide any timestamp information. If neither the format that successfully matches the string nor this parameter provide the time zone, the time zone is supplied by the system. For actions that are attributed to the current user, the local time zone setting from the profile for the current user is applied. For actions that are attributed to the workflow user account, the global default time zone is applied. For a list of time zone IDs, see [JodaTime](http://joda-time.sourceforge.net/timezones.html). |

**Return Value**

| Type | Description |
| number | A timestamp representation of the specified string. |

### toPeriod﻿

```
static toPeriod(period)
```

Creates a period representation of an argument.

**Parameters**

| --- | --- | --- |
| period | number, string | A duration in milliseconds as either a number or a string. The string representation is a series of numeric values followed by the abbreviation that represents the timespan, in descending order. For example, 3w4d23h58m. |

**Return Value**

| Type | Description |
| Period | The period representation of the specified argument. |

**Example**

```
issue.fields.Estimation = dateTime.toPeriod(3 * 3600 * 1000); // 3h in ms
issue.fields.Estimation = dateTime.toPeriod('3h'); // short form
issue.fields.Estimation = dateTime.toPeriod('2w4d3h15m'); // full form
```

**See Also**

- For possible usages, see PeriodProjectCustomField.

- [date-time](/help/youtrack/devportal/v1-date-time.html)
- [Functions](/help/youtrack/devportal/v1-date-time.html#functions)
- [after](/help/youtrack/devportal/v1-date-time.html#after)
- [before](/help/youtrack/devportal/v1-date-time.html#before)
- [format](/help/youtrack/devportal/v1-date-time.html#format)
- [parse](/help/youtrack/devportal/v1-date-time.html#parse)
- [toPeriod](/help/youtrack/devportal/v1-date-time.html#toPeriod)

Change Log[entities](jetbrains__com__help__youtrack__devportal__v1-entities.md)

- Privacy & Security
- Terms Of Use
- Trademarks
- Legal

Copyright © 2000–2026 JetBrains s.r.o.
