Dayjs does not preserve timezone information when serializing to JSON string
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
When I do this
```typescript
const timestamp = dayjs("2019-11-26T17:28:35.518+03:00")
const actualJson = JSON.stringify(timestamp)
const expectedJson = "\"2019-11-26T17:28:35.518+03:00\""
```
I want `actualJson` to be equal to `expectedJson`. However, `actualJson` is `"\"2019-11-26T14:28:35.518Z\""`.
With Moment.js I can do this:
```typescript
moment.fn.toJSON = function() { return this.format(); }
```
in order to get my expected JSON string with the preserved timezone information, see https://momentjs.com/docs/#/displaying/as-json/
How can I achieve this in dayjs? I am new to Javascript/Typescript and my compiler tells me that `dayjs.fn` does not exist. What would be the right workaround?
**Information**
- Day.js Version 1.8.28
- OS: Windows 8.1
- Time zone: CEST (Berlin)
Contributor guide
Assessment
This issue has not been assessed yet.