The PHP only creates a string representation of a javascript Date object.
If you echo that string to your javascript, it will create a Date object.
Ex: if $graphData contains this:
$graphData = "[$newDate, 303.51, 300]...";
and the javascript contains this:
data.addRows([<?php echo $graphdata ;?>]);
Then when you open it in a browser, you get this in the js:
data.addRows([[new Date(2013, 2, 20, 18, 18), 303.51, 300]...]);
On Saturday, March 23, 2013 8:02:54 PM UTC-4, Jan wrote:
>
> I still understand it when I do that in PHP. My problem is that is has to
> be coded in the java part of the code. Or can I transfer a PHP object date
> to the Java part of the code?
>
> Op zondag 24 maart 2013 00:59:40 UTC+1 schreef asgallant het volgende:
>>
>> Try something like this:
>>
>> // assumes $date contains the date string
>> $dateTimeArr = explode(' ', $date);
>> $dateArr = explode('-', $dateTimeArr[0]);
>> $year = (int) $dateArr[2] + 2000;
>> $day = (int) $dateArr[0];
>> switch ($dateArr[1]) {
>> case 'Jan':
>> $month = 0;
>> break;
>> case 'Feb':
>> $month = 1;
>> break;
>> case 'Mar':
>> $month = 2;
>> break;
>> case 'Apr':
>> $month = 3;
>> break;
>> case 'May':
>> $month = 4;
>> break;
>> case 'Jun':
>> $month = 5;
>> break;
>> case 'Jul':
>> $month = 6;
>> break;
>> case 'Aug':
>> $month = 7;
>> break;
>> case 'Sep':
>> $month = 8;
>> break;
>> case 'Oct':
>> $month = 9;
>> break;
>> case 'Nov':
>> $month = 10;
>> break;
>> case 'Dec':
>> $month = 11;
>> break;
>> default:
>> // should never trigger
>> }
>> $timeArr = explode(':', $dateTimeArr[1]);
>> $hour = $timeArr[0];
>> $minute = $timeArr[1];
>>
>> $newDate = "new Date($year, $month, $day, $hour, $minute)";
>>
>> On Saturday, March 23, 2013 7:40:56 PM UTC-4, Jan wrote:
>>>
>>> I Know, that's exactly the question; how do I do that (in code) from out
>>> the excisting array?
>>>
>>> Op zondag 24 maart 2013 00:38:20 UTC+1 schreef asgallant het volgende:
>>>>
>>>> You need to convert your dates into this format: new Date(year, month,
>>>> day, hour, minute, second). Months are zero-indexed in javascript, so
>>>> January is 0, February is 1, March is 2, etc. Your date "20-Mar-13 18:18"
>>>> would be new Date(2013, 2, 20, 18, 18).
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.