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

查看:47
本文介绍了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")

您使用的语法用于解析给定的字符串到日期对象,使用指定甲酸盐

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天全站免登陆