I calculate datetime using
datetime_from_moment = moment.utc().utcOffset('+0530')
and then convert it to string so I could save it to firebase realtime database like this:
datetime_from_moment_string = datetime_from_moment.toString()
after sometime I get that datetime (which is in string format) from database to do some calculations. To do those calculations, I have to convert that string to moment type. How do I do this?
A string type moment datetime looks like this Fri Mar 01 2019 22:07:56 GMT+0530
To convert it I do this datetime_converted = moment(datetime_from_moment_string)
but I get this error:
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: Fri Mar 01 2019 22:10:42 GMT+0530, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:320:98)
at configFromString (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2368:15)
at configFromInput (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2594:13)
at prepareConfig (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2577:13)
at createFromConfig (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2544:44)
at createLocalOrUTC (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2631:16)
at createLocal (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:2635:16)
at hooks (E:\workspace_javascript\testingProject\node_modules\moment\moment.js:12:29)
at Object.<anonymous> (E:\workspace_javascript\testingProject\index.js:58:26)
at Module._compile (internal/modules/cjs/loader.js:688:30)