---
title: "How to convert the date format to UT in JSON?"  
description: "How to convert the date format to UT in JSON?"  
author: "Utpal Vishwas"  
published: 2023-05-11  
updated: 2023-05-15  
canonical: https://www.mindstick.com/forum/158272/how-to-convert-the-date-format-to-ut-in-json  
category: "json"  
tags: ["json", "jsonobject"]  
reading_time: 1 minute  

---

# How to convert the date format to UT in JSON?

How to [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) the [date format](https://www.mindstick.com/forum/1976/date-format-comparison-issue) to UT in [JSON](https://www.mindstick.com/forum/34446/convert-json-string-to-object)?

## Replies

### Reply by Aryan Kumar

To convert the [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format) to UT in JSON, you can use the following steps:

1. Get the date object.
2. Use the `toUTCString()` method to convert the date object to a string in UTC format.
3. Set the `date` property of the JSON object to the string in UTC format.

Here is an example of how to convert the date format to UT in JSON:

Code snippet

```plaintext
const date = new Date();
const jsonObject = {
  date: date.toUTCString()
};
```

The `date` property of the JSON object will now contain the date in UTC format.

Here is an example of how to print the JSON object:

Code snippet

```plaintext
console.log(jsonObject);
```

This will print the following output:

Code snippet

```plaintext
{
  "date": "2023-05-15T00:00:00.000Z"
}
```


---

Original Source: https://www.mindstick.com/forum/158272/how-to-convert-the-date-format-to-ut-in-json

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
