Any way to parse a time string using Moment.js but ignore timezone info?

前端 未结 10 1642
深忆病人
深忆病人 2020-12-30 01:56

Given the volume of Timezone questions, I would have thought to be able to find the answer to this issue, but haven\'t had any success.

Is there a way using mo

10条回答
  •  猫巷女王i
    2020-12-30 02:24

    If you know for sure your input string is in the ISO-8601 format, you could just strip off the last 5 digits and use that in the Moment constructor.

    var input = "2012-12-31T00:00:00+0000"
    input = input.substring(0, input.length-5)
    moment(input).toString()
    > "Mon Dec 31 2012 00:00:00 GMT-0600"
    

提交回复
热议问题