Search code examples
phpjqueryjsongantt-chartmicrotime

JS microtime vs php microtime


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 ?


Solution

  • 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.