简体   繁体   中英

Convert Database datetime or date in Javascript new Date(GMT) format

如何在javascript中将数据库日期(例如mm / dd / yyyy,dd / mm / yyyy,yyyy / mm / dd)转换为新的Date()(GMT)或(IST)格式

I recommend you to use a JS library called moment.js to simplify all date's management.

Example:

 moment("12/25/2016", "MM/DD/YYYY").format("Format/you/want"); 

Source: http://momentjs.com/docs/

you could use toUTCString() Method

var d = new Date("Your date"); 
var n = d.toUTCString();

This returns GMT format, hope this is what you were looking for :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM