Base solution for your next web application
Open Closed

MomentJs and JSON.stringify #7774


User avatar
0
ectabyte created

Hi! I have a dto with a moment (date and time) property, when JSON.stringify is called it changes the moment value. I want to send this date-time value to the server without any chages or conversations (and also get it back). Please help on this topic! Thanks!


1 Answer(s)
  • User Avatar
    0
    ectabyte created

    for anybody has this issue.. you have to set the parameter keepOffset to true in the toISOString() function like this:

    toJSON(data?: any) { ... data["yourProperty"] = this.date ? this.date.toISOString(true) : <any>undefined; ... }