moment.js 24h格式 [英] moment.js 24h format

查看:196
本文介绍了moment.js 24h格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以24小时格式而不是12小时显示时间?

How do I display my time in 24h format instead of 12?

我正在使用moment.js。

I am using moment.js.

我很确定这些行可能与它有关。

I am pretty sure that these lines could have something to do with it.

   meridiem : function (hours, minutes, isLower) {
        if (hours > 11) {
            return isLower ? 'pm' : 'PM';
        } else {
            return isLower ? 'am' : 'AM';
        }
    },

如何更改?

推荐答案

你读过文档

它声明

H, HH       24 hour time
h, or hh    12 hour time (use in conjunction with a or A)

因此,将您的时间表示为 HH 将为您提供24小时格式, hh 将给出12h格式。

Thus, stating your time as HH will give you 24h format, and hh will give 12h format.

这篇关于moment.js 24h格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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