momentjs - Javascript date convert to timezone with format -


how can create date object, convert timzone datestring timezone , format below

var date="20160317t073000"; var format = "yyyymmddthhmmss"; var timezone ="america/new_york"  var newtimezone="asia/kolkata" 

i want date convert newtimezone, tried moment.js, converting browser timezone

date=moment(date,format);  date.tz(timezone);  console.log(moment(date).format()); 

moment.js seems have : http://momentjs.com/timezone/

convert dates between timezones

var newyork    = moment.tz("2014-06-01 12:00", "america/new_york"); var losangeles = newyork.clone().tz("america/los_angeles"); var london     = newyork.clone().tz("europe/london");  newyork.format();    // 2014-06-01t12:00:00-04:00 losangeles.format(); // 2014-06-01t09:00:00-07:00 london.format();     // 2014-06-01t17:00:00+01:00 

to convert format, should :

'20160317t073000'.replace(/([0-9]{4})([0-9]{2})([0-9]{2})t([0-9]{2})([0-9]{2})([0-9]{2})/, '$1-$2-$3t$4:$5:$6') 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -