Question

I'm trying to convert timezone in javascript from "Asia/Kolkata" to "America/Los_Angeles" but getting error : "Timezone "Asia/Kolkata" is either incorrect, or not loaded in the timezone registry."

following is my code:

<html>
<head>
  <script type="text/javascript" src="includes/javascript/jquery.js"></script>
  <script type="text/javascript" src="includes/javascript/timezone/src/date.js"></script>
</head>
<body>
  <script type="text/javascript">
    $(document).ready(function(){
        alert(new Date);
    timezoneJS.timezone.zoneFileBasePath = '/javascript/timezone/tz';
    timezoneJS.timezone.defaultZoneFile = ['asia', 'backward', 'northamerica'];
    timezoneJS.timezone.loadingScheme = timezoneJS.timezone.loadingSchemes.MANUAL_LOAD;
    timezoneJS.timezone.loadZoneJSONData('/javascript/timezone/tz/all-tz.json', true);
    timezoneJS.timezone.init();
    var dt = new timezoneJS.Date("2014/02/18 16:30:21 +0000", "Asia/Kolkata");
    dt.setTimezone("America/Los_Angeles");
    console.log(dt);
    });
</script>
</body>
</html>

I've no idea what exactly wrong with it.

No correct solution

OTHER TIPS

I am using timezone.js and code is:

var dt = new timezoneJS.Date("2012/04/10 10:10:30 +0000", 'Asia/Kolkata'); dt.setTimezone("America/Los_Angeles");

console.debug(dt);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top