使用矩javascript和DateTimePicker的无效日期 [英] Invalid date using moment javascript and DateTimePicker

查看:160
本文介绍了使用矩javascript和DateTimePicker的无效日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是使用dateTimePicker和moment.js发生的:

This happens using dateTimePicker and moment.js:

如果我使用以下行代码:

If I use this line code:

 console.info($('#inp_date_time_'+value.fila+'_id').val());

打印此日期格式:

2015年4月9日08:31

04/09/2015 08:31

然后,如果我使用此行代码:

then If I use this line code:

moment($('#inp_date_time_'+value.fila+'_id').val()).format('YYYY-DD-MM HH:mm:ss');

打印此日期格式:

2015-09-04 08:31:00

2015-09-04 08:31:00

没关系,但是如果我选择的日期大于12天(例如:2015年9月13日)

and it's ok, but If I select a day more bigger that 12 (example : 13/09/2015)

我有无效的日期",我认为需要几天的时间,或者我不知道.

I have "invalid date" , I think that take the days like months , or I don't know.

我该如何解决?对不起,我的英语.

How can I fix this?, sorry my english.

推荐答案

更好的选择是在创建moment对象时指定dateFormat.因此,将moment($('#inp_date_time_'+value.fila+'_id').val()).format('YYYY-DD-MM HH:mm:ss');替换为moment($('#inp_date_time_'+value.fila+'_id').val(),, 'DD/MM/YYYY HH:mm').format('YYYY-DD-MM HH:mm:ss');

Better option would be to specify dateFormat when creating a moment object. So replace moment($('#inp_date_time_'+value.fila+'_id').val()).format('YYYY-DD-MM HH:mm:ss'); with moment($('#inp_date_time_'+value.fila+'_id').val(),, 'DD/MM/YYYY HH:mm').format('YYYY-DD-MM HH:mm:ss');

这篇关于使用矩javascript和DateTimePicker的无效日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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