日期被解释为不同的格式 [英] Date is interpreted as being in a different format

查看:132
本文介绍了日期被解释为不同的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

  $('#datepicker').datepicker({
        inline: true,
        onSelect: function(dateText, inst) {
            var d = new Date(dateText);
            alert("DateText=>"+ dateText + "," + "DATE =>" + d);
            $('#calendar').fullCalendar('gotoDate', d);
        }
    }); 
})

我的错误:

我的问题这个函数是从fullCalendar以dd / mm / yyyy的形式传递dateText ...然后使用这个形式创建一个新的日期,它正在搞砸它,认为日期应该是mm / dd / yy。任何人都可以帮助我解决这个问题吗?

My problem is that the function is being passed dateText from fullCalendar in the form dd/mm/yyyy...it is then creating a new date using this and it is messing it up, thinking that the date should be in the form mm/dd/yy. Can anyone help me fix this please?

推荐答案

您正在提醒dateText,但将日期对象传递给日历。查看FullCalendar API的格式为'gotDate'参数。您可以使用

You are alerting the dateText but passing a date object to calendar. Look at FullCalendar API for format of 'gotDate' argument. You can use

d.getFullYear(), d.getMonth() and d.getDate() to convert

这篇关于日期被解释为不同的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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