TomPHP TomPHP - 2 months ago 30
Javascript Question

Convert DateTime to Local Timezone - Sugarcrm Moment js

I am trying to change a specific datetime to user/local timezone datetime. But i couldnt able to convert it. I tried all possible solutions availabe for javascript and tried moment js. It still give me

invalid date

My DateTime Object:

{date: "2017-07-14 14:23:30.000000", timezone_type: 3, timezone: "UTC"}

What I am trying is to convert it to the user timezone or local timezone.

Is there any options available in Moment.js to do it?

In my SugarCRM JavaScript, I couldnt use

Methods I tried:

Convert UTC date time to local date time using JavaScript

Jay Jay
Answer Source

Not sure if this helps you, but there you go:

var myDateTime = {date: "2017-07-14 14:23:30.000000", timezone_type: 3, timezone: "UTC"};
var myDate = Date(;
var localDateTime = myDate.getFullYear()+"-"+("0"+(1+myDate.getMonth())).slice(-2)+"-"+("0"+myDate.getDate()).slice(-2)+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds()+"."+myDate.getMilliseconds();


"2017-07-14 16:23:30.0"