如何在moment.js 中获取月份的简称? [英] how to get shortname of month in moment.js?

查看:29
本文介绍了如何在moment.js 中获取月份的简称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功找到月份的全名,但我想要月份的简称.谁能帮我.我正在使用 Moment.js 我已经成功找到了月份,但我想要简短的形式
这是我的代码:

i have successfully find the full name of month but i want short name of month. Can anyone help me. I am using Moment.js i have successfully find the month but i want in short form
here is my code :

var date = '<?php echo date("Y-m-d") ?>';
var Month = moment(date, 'YYY-MM-DD').format('DD/MMMM')
console.log(Month);

它返回我 06/February,但我想要 06/Feb

it returns me 06/February, But i want 06/Feb

提前致谢:)

推荐答案

您没有使用正确的格式字符串,请使用 MMM 而不是 MMMM 参见 文档

You are not using correct format string, use MMM instead of MMMM see Docs

console.log(moment().format('DD/MMM'))

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

这篇关于如何在moment.js 中获取月份的简称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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