Trying to implement momentjs to display localtime
javascript, momentjs
Solution
Moment has two different `utc` functions:
One is on a moment instance, used to switch the mode to UTC.
moment(input).utc()
The other is on the moment prototype, used to interpret the input as already in UTC.
moment.utc(input)
So, you want this syntax:
moment.utc(obj.created_on).local().format()
Problem
Before asking this question I have searched all stackoverflow and read the docs but I can't just understand how to convert one UTC date to local time of an user and display it in his format. I keep trying different methods but I keep getting the same time again and again. so my django returns obj.created_on in UTC as - 2013-12-26T13:52:24 - no timezone Info here but I know its UTC Now I want momentjs to auto detect the user's timezone and convert it in that timezone. Can I have proper syntax for the same? I was trying this as well: ``` new_date = moment(obj.created_on).utc().local().format() ```