Javascript DateFormat for different timezones

后端 未结 9 2070
小蘑菇
小蘑菇 2020-12-16 16:42

I\'m a Java developer and I\'m used to the SimpleDateFormat class that allows me to format any date to any format by settings a timezone.

Date date = new Dat         


        
9条回答
  •  -上瘾入骨i
    2020-12-16 16:56

    This is an old question, but since I found it:

    As mentioned, there's nothing reasonable built-in.

    As for libs, there is Moment Timezone for Moment.js.

    Here is a JSfiddle with an example: http://jsfiddle.net/kunycrkb/

    The same code inline:

    var m = moment("2014-06-01T13:05:00Z");
    var f = "HH:mm z";
    
    $("#results").text(m.tz("UTC").format(f) + " is " + m.tz("EST").format(f) +  "!");
    

提交回复
热议问题