php转化输入日期为Unix 纪元到当前时间的秒数 日期筛选

多条件筛选时 日期筛选 部分

demo   http://pan.baidu.com/s/1hqGF5Ik

时间输入控件http://www.jq22.com/jquery-info332

输入控件

<!DOCTYPE html>

<html >

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

<link rel="stylesheet" type="text/css" href="./screen/jquery.datetimepicker.css"/>

</head>

<body>

	<form action="time.php" method="get">

from <input type="text" id="datetimepicker6" name="from"/>

to <input type="text" id="datetimepicker7" name="to"/>

<input type="submit" />

</form>

	

	

</body>

<script src="./screen/jquery.js"></script>

<script src="./screen/jquery.datetimepicker.js"></script>

<script>





$('#datetimepicker6').datetimepicker();

$('#datetimepicker7').datetimepicker();





</script>

</html>

 输入格式转化为时间戳

<?php

//条件筛选日期函数 将输入日期转化为 Unix 时间戳 

$timef=trim($_GET['from']);

$timeto=trim($_GET['to']);

var_dump($timef);

echo "<br/>";

//$timest="2014/12/12 13:43:21";



//

//sscanf($timest,"%d/%d/%d %d:%d:%d",$y,$m,$d,$h,$i,$s);有输入控件的时候最好





//$date1=mktime($h,$i,$s,$m,$d,$y);

//echo date('Y-m-d H i s', $date1);

//函数

function dates_range($time)

{

    $k = preg_split("/[\s\/\:]+/", $time);

    $dates=mktime($k[3],$k[4],0,$k[1],$k[2],$k[0]);

	return $dates;

}

//

echo "<br/>";

$date1=dates_range($timef);

echo $date1;

echo "<br/>";

echo date('Y-m-d H i s', $date1);



?>

 

你可能感兴趣的:(unix)