我怎样才能正确地显示日期YYYY-MM-DD HH:MM:SS用HTML5和Angularjs? [英] How can I show correctly Dates yyyy-MM-dd hh:mm:ss with HTML5 and Angularjs?

查看:1129
本文介绍了我怎样才能正确地显示日期YYYY-MM-DD HH:MM:SS用HTML5和Angularjs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建日期和时间输入,但我不明白这样做的方式。

I'm trying to create an input with date and time but I don't get the way of doing it.

我试着输入的日期时间

<tr>
  <td>Date</td>
    <td><input type="datetime" name="fecha"
    placeholder="dd-MM-dd HH:mm:ss" size="16"
    ng-model="data.action.date" /></td>
  <tt>value = {{data.action.date | date: "yyyy-MM-dd HH:mm:ss"}}</tt>
</tr>

和我得到这个

和我试过,以及输入的日期时间本地喜欢的例如,在角DOC

And I've tried as well input datetime-local like the example in angular doc

<tr>
  <td>Date</td>
    <td><input type="datetime-local" name="fecha"
    placeholder="dd-MM-dd HH:mm:ss" size="16"
    ng-model="data.action.date" /></td>
  <tt>value = {{data.action.date | date: "yyyy-MM-dd HH:mm:ss"}}</tt>
</tr>

和我得到这个

我怎么能显示与日期和时间输入?

How could I show the input with a date and time?

推荐答案

我建议使用角矩指令做所有的日期格式在角:的 https://github.com/urish/angular-moment

I recommend using the angular-moment directive for doing all date formatting in Angular: https://github.com/urish/angular-moment.

Moment.js是一个伟大的JavaScript库格式,转换和做所有的日期/时间相关的任务 - 在角角会儿公开这个库很容易

Moment.js is a great JavaScript library for formatting, converting and doing all date/time related tasks - angular-moment just exposes this library easily within Angular.

您可以简单地使用amDateFormat过滤模板中,如下图所示。

You can simply use the amDateFormat filter within your template as shown below.

<span>{{message.time | amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a'}}</span>

更多信息请参见上面的链接。

See the above link for more information.

这篇关于我怎样才能正确地显示日期YYYY-MM-DD HH:MM:SS用HTML5和Angularjs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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