Google Charts API datetime unix格式? [英] Google Charts API datetime unix format?

查看:101
本文介绍了Google Charts API datetime unix格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让Google Charts了解日期时间格式。我使用了一个例子[1],其中日期时间格式设置为简单月份的日期和年份,但我将其更改为采用类型为日期时间的输入。一个例子可以在以下页面找到:



http://www.sccs.swarthmore.edu/users/09/leo/cgi-bin/viewer.php



代码的开始如下:

  data.addColumn('datetime','Date'); 
data.addColumn('number','Active or not');
data.addRows(1768);
data.setValue(0,0,new Date(1306192258));
data.setValue(0,1,1);

为什么Google会将该日期格式更改为1970年1月15日? (开始的时代?)



谢谢!

[1] http://www.beakkon.com/geek/how-to/create使用google-charts-api

解决方案

试试这个:

  data.addColumn('datetime','Date'); 
data.addColumn('number','Active or not');
data.addRows(1768);
var d = new Date();
d.setTime(1306192258 * 1000);
data.setValue(0,0,d);
data.setValue(0,1,1);


I'm having a hard time getting Google Charts to understand the datetime format. I used an example [1] where the datetime format is set to a simple month day and year, but I changed it to take an input of type datetime. An example is available the following page:

http://www.sccs.swarthmore.edu/users/09/leo/cgi-bin/viewer.php

The start of the code is as follows:

data.addColumn('datetime', 'Date');
data.addColumn('number', 'Active or not');      
data.addRows(1768);
data.setValue(0, 0, new Date(1306192258));
data.setValue(0, 1, 1);

Why will Google change that Date format to Jan 15, 1970? (Start of Epoch time?)

Thanks!

[1] http://www.beakkon.com/geek/how-to/create-interactive-charts-using-google-charts-api

解决方案

Try this:

data.addColumn('datetime', 'Date');
data.addColumn('number', 'Active or not');      
data.addRows(1768);
var d = new Date();
d.setTime(1306192258*1000);
data.setValue(0, 0, d);
data.setValue(0, 1, 1);

这篇关于Google Charts API datetime unix格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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