且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取特定格式的日期/时间戳

更新时间:2023-01-22 14:12:40

如果使用第三方库没有任何问题,可以使用Moment .js,它是一个漂亮的日期和格式库

If you dont have any problem using third party library, you can use Moment.js,it is a beautiful library for dates and formatting

在moment.js中,您可以将其格式化为以下格式

In moment.js,you can format it as the following

var day = moment("2016-11-01");
console.log(day);
console.log(day.format("DD-MMM-YYYY HH:MM"));

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.2/moment.js"></script>

希望这会有所帮助