1

我在 JS 中有一个 datetime 变量,它是:

var date_start   = dateFormat(newJobForm.time_start, "yyyy-mm-dd-HH-MM"); 
var date_end     = dateFormat(newJobForm.time_end, "yyyy-mm-dd-HH-MM"); 

主要问题是:我不能只显示分钟

当我将日期传递给 PHP 的date()函数时,由于 and 之间的关系:,它不会保存它。我试过了,但没有用。Hiexplode()-

URL 是:my_controller/abcd^5^2012-10-15-15-15^2012-10-18-17-30并且我在 CakePHP 动作中从 JS 获取时间的控制器是:

$time_start          = $explode_item[2];                 
$time_end            = $explode_item[3]; 

$dateStart = strtotime ( date('Y-m-d H:i', $time_start) ) ;
            $dateStartArray['Y'] = date ( 'Y' , $dateStart );
            $dateStartArray['m'] = date ( 'm' , $dateStart );
            $dateStartArray['d'] = date ( 'd' , $dateStart );
            $dateStartArray['H'] = date ( 'H' , $dateStart );
            $dateStartArray['i'] = date ( 'i' , $dateStart );
4

1 回答 1

0

我得到了答案:
控制器应该是

$dateStart = date("Y-m-d H:i",strtotime ('+1 hour', strtotime (date("Y-m-d H:i",$time_start))));
$dateEnd   = date("Y-m-d H:i",strtotime ('+1 hour', strtotime (date("Y-m-d H:i",$time_end))));

我们需要在js中将时间转换为Echop

var d = new Date(value); var epochtime = (d.getTime()-d.getMilliseconds())/1000;

完毕 !:)

于 2012-10-18T16:25:33.730 回答