4

i'm using a plugin for a ganttchart. i feed the plugin with json: Plugin: GitHub - JQuery Gantt

{ "name": "Zbigniew Kowalski",
   "desc": "Administrator",
   "values": [
       {"from": "/Date(1310508000000)/", "to": "/Date(1311026400000)/", "desc": "<b>Type</b>: Task<br/><b>name</b>: Task 5<br/><b>Description</b>: Task desc."}
     ]
},

So if i try to generate such a block uhm i get some decent problems with the microtime.

microtime in php gives me: 0.77424900 1315815507 and time: 1315815507

but i need something like 1310508000000.

it can't be the key just to add some 0's ?

Jens
  • 345
  • 1
  • 6
  • 19

3 Answers3

3

yu should use microtime(true) to geat a float-value and then multiply it by 1000 to get microseconds:

$time = microtime(true)*1000;

take a look at the documentation for more information.

oezi
  • 51,017
  • 10
  • 98
  • 115
0

This is the way to construct a JavaScript date object from a PHP timestamp:

new Date('<?php echo date('r'); ?>');
Shef
  • 44,808
  • 15
  • 79
  • 90
  • this still isn't the solution, microtime(true) give seconds, not microseconds. you'll still have to multiply. – oezi Sep 12 '11 at 08:37
0

in you JS you could do:

var timer = 1315815507;
var float = Math.round(parseInt(timer)/1000000)*1000000; 

this will give you: 1316000000

live example at: http://jsfiddle.net/DBjS8/1/

WooDzu
  • 4,771
  • 6
  • 31
  • 61