2014-01-11 43 views
1

由於某些原因,我使用的時間戳沒有正確轉換爲圖形。該圖表示他們是01/16/1970 [時間戳:1389429242]。我正在使用strtotime(php函數)來生成時間戳。如何使用php爲此生成正確的時間戳?NVD3.js | php | unix時間戳不起作用

代碼:

<script> 
    nv.addGraph(function() { 
     var chart = nv.models.lineWithFocusChart(); 

     chart.xAxis 
      .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); 
     chart.x2Axis 
      .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); 

     chart.yAxis 
      .tickFormat(d3.format(',f')); 
     chart.y2Axis 
      .tickFormat(d3.format(',f')); 

     d3.select('#chart svg') 
       .datum(
        [ 
         { 
          key : 'Current' , 
          color : '#2ca02c', 
          values : [ 
           { x: 1389429242 , y:15 }, 
           ... 
          ] 
         }, 
         { 
          key : 'Backlog' , 
          color : '#ff7f0e', 
          values : [ 
           { x: 1389429242 , y:50 }, 
           ... 
          ] 
         } 
        ] 
       ) 
       .call(chart); 

     nv.utils.windowResize(chart.update); 

     return chart; 
    }); 
</script> 

回答

1

因此很明顯,JS時間戳爲毫秒。所以我不得不乘我的PHP時間戳1000我的工作。

已解決