JavaScript的Google Analytics控制台日期格式错误 [英] Google Analytics Dashboard Date Format Error With JavaScript
问题描述
我正在创建Google Analytics信息中心。在那里开始日期&使用JQuery日期选择器插入结束日期。我以mm / dd / yyyy格式插入日期。但我想在yyyy-mm-dd中提交它们。我使用以下代码来做到这一点。
I'm creating a Google Analytics Dashboard. In there the Start Date & End Date is inserted using JQuery Date Picker. I am inserting dates in the mm/dd/yyyy format. But I want to submit them in the yyyy-mm-dd. I have used the following code to do that.
$("#to_date, #from_date").datepicker({maxDate: new Date(),dateFormat:'yyyy-mm-dd'});
在那里插入的日期为20142014-07-01而不是2014-07-01。所以我将格式更改为yy-mm-dd。之后我在提交此日期后收到错误说
** {error:{errors:[{domain: global,reason:invalidParameter,message:无效的值'2014-07-24'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' ,locationType:参数,location:end-date},{domain:global,reason:invalidParameter,message:无效值2014-07- 01'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' ,locationType:参数,位置:开始日期},代码:400,消息:无效值'2014-07-24'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' }} **
我使用的是JavaScript。
我无法理解我该怎么办。谁能告诉我怎么做?
Thnaks&问候,
Chiranthaka
At there the date inserted as 20142014-07-01 not as 2014-07-01. So I changed the format to yy-mm-dd. After that I got an error when after submit this date saying
" **{"error":{"errors":[{"domain":"global","reason":"invalidParameter","message":"Invalid value ' 2014-07-24 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'","locationType":"parameter","location":"end-date"},{"domain":"global","reason":"invalidParameter","message":"Invalid value ' 2014-07-01 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'","locationType":"parameter","location":"start-date"}],"code":400,"message":"Invalid value ' 2014-07-24 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'"}}** "
I am using JavaScript.
I cannot understand what should I do. Can anyone show me how to do this?
Thnaks & regards,
Chiranthaka
推荐答案
( #to_date,#from_date)。datepicker({maxDate: new 日期(),dateFormat:' yyyy-mm-dd'});
("#to_date, #from_date").datepicker({maxDate: new Date(),dateFormat:'yyyy-mm-dd'});
在那里插入的日期为20142014-07-01而不是2014-07-01。所以我将格式更改为yy-mm-dd。之后我在提交此日期后收到错误说
** {error:{errors:[{domain: global,reason:invalidParameter,message:无效的值'2014-07-24'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' ,locationType:参数,location:end-date},{domain:global,reason:invalidParameter,message:无效值2014-07- 01'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' ,locationType:参数,位置:开始日期},代码:400,消息:无效值'2014-07-24'。值必须与以下正则表达式匹配:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)' }} **
我使用的是JavaScript。
我无法理解我该怎么办。谁能告诉我怎么做?
Thnaks&问候,
Chiranthaka
At there the date inserted as 20142014-07-01 not as 2014-07-01. So I changed the format to yy-mm-dd. After that I got an error when after submit this date saying
" **{"error":{"errors":[{"domain":"global","reason":"invalidParameter","message":"Invalid value ' 2014-07-24 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'","locationType":"parameter","location":"end-date"},{"domain":"global","reason":"invalidParameter","message":"Invalid value ' 2014-07-01 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'","locationType":"parameter","location":"start-date"}],"code":400,"message":"Invalid value ' 2014-07-24 '. Values must match the following regular expression: '[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)'"}}** "
I am using JavaScript.
I cannot understand what should I do. Can anyone show me how to do this?
Thnaks & regards,
Chiranthaka
datepicker
小部件的格式字符串使用yy
代表四位数年份。通过将格式设置为yyyy-mm-dd
,您已经告诉它将四位数年份跟随四位数年份,这就是为什么你这么做的原因获取20142014
。
将日期格式更改为yy-mm-dd
你应该得到正确的输出。
http://api.jqueryui.com/datepicker/#utility-formatDate [ ^ ]
The format string for thedatepicker
widget usesyy
to represent the four-digit year. By setting the format toyyyy-mm-dd
, you've told it to put the four-digit year followed by the four-digit year, which is why you're getting20142014
.
Change the date format toyy-mm-dd
and you should get the correct output.
http://api.jqueryui.com/datepicker/#utility-formatDate[^]
这篇关于JavaScript的Google Analytics控制台日期格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!