Moment.js中的DD / MM / YYYY日期格式 [英] DD/MM/YYYY Date format in Moment.js

查看:1043
本文介绍了Moment.js中的DD / MM / YYYY日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用moment.js将当前日期更改为此格式(DD / MM / YYYY)?

How can i change the current date to this format(DD/MM/YYYY) using moment.js?

我尝试过以下代码。

$scope.SearchDate = moment(new Date(), "DD/MM/YYYY");

但它返回 0037-11-24T18:30:00.000Z 。没有帮助格式化当前日期。

But it's return 0037-11-24T18:30:00.000Z. Did't help to format current date.

推荐答案

您需要致电 format()函数获取格式化值

You need to call format() function to get the formatted value

$scope.SearchDate = moment(new Date()).format("DD/MM/YYYY")
//or $scope.SearchDate = moment().format("DD/MM/YYYY")

您使用的语法用于解析使用指定的formate

The syntax you have used is used to parse a given string to date object by using the specified formate

这篇关于Moment.js中的DD / MM / YYYY日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆