---
title: "How do I format a Microsoft JSON date?"  
description: "How do I format a Microsoft JSON date?"  
author: "Utpal Vishwas"  
published: 2023-05-11  
updated: 2023-05-15  
canonical: https://www.mindstick.com/forum/158267/how-do-i-format-a-microsoft-json-date  
category: "json"  
tags: ["json", "format"]  
reading_time: 2 minutes  

---

# How do I format a Microsoft JSON date?

How do I [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format) a [Microsoft](https://www.mindstick.com/articles/12301/microsoft-is-trying-to-kill-passwords) [JSON](https://www.mindstick.com/forum/34446/convert-json-string-to-object) [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner)?

## Replies

### Reply by Aryan Kumar

Microsoft JSON dates are formatted as a string with the following format:

Code snippet

```plaintext
/Date(millisecondsSinceUnixEpoch)/
```

For example, the date 2023-05-15 00:00:00 UTC would be formatted as follows:

Code snippet

```plaintext
/Date(1652454400000)/
```

To format a Microsoft JSON date, you can use the following steps:

1. Get the date object.
2. Use the getTime() method to get the number of milliseconds since the Unix epoch.
3. Use the toUTCString() method to convert the number of milliseconds to a string in UTC format.
4. Surround the string with forward slashes (/).

Here is an example of how to format a Microsoft JSON date:

Code snippet

```plaintext
const date = new Date();
const jsonDate = `/Date(${date.getTime()})/`;
```

The jsonDate variable will now contain the date formatted in Microsoft JSON format.

You can also use the following function to format a Microsoft JSON date:

Code snippet

```plaintext
function formatMicrosoftJSONDate(date) {
  return `/Date(${date.getTime()})/`;
}
```

Here is an example of how to use the formatMicrosoftJSONDate() function:

Code snippet

```plaintext
const date = new Date();
const jsonDate = formatMicrosoftJSONDate(date);
```

The jsonDate variable will now contain the date formatted in Microsoft JSON format.


---

Original Source: https://www.mindstick.com/forum/158267/how-do-i-format-a-microsoft-json-date

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
