Convert the CST time to local browser time

98 views Asked by At

I am using Moment Js to convert the CST time to local browser time. My data is coming from back-end code is in "America/Chicago" timezone. I want to convert the "America/Chicago" timezone to Browser time. But date is not converted correctly.

Below is the code.

var currentDate = moment.parseZone('2018-10-02 06:30:53').local().format('MM/DD/YYYY');
var currentTime = moment.parseZone('2018-10-02 06:30:53').local().subtract({
  'minutes': 0
}).format('hh:mm A');
console.log(currentDate, currentTime)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js"></script>

Input Date: "2018-10-03 01:46:40" ('america/chicago')

Output Date: "10/03/2018 07:16 AM" (IST time zone)

Expected Output: 10/03/2018 12:16 PM" (IST time zone)

0

There are 0 answers