01.
<HTML>
02.
<title>Untitled Document</title>
03.
<?
04.
$objConnect
= mssql_connect(
"192.168.1.3\SQL2005"
,
"sa"
,
"pass"
)
or
die
(
"Error Connect to Database"
);
05.
$objDB
= mssql_select_db(
"db"
);
06.
?>
07.
08.
<body>
09.
<?
10.
$strSQL
=
"select CONVERT(varchar(10),createdate,120) as createdate,createtime,CONVERT(varchar(10),closedate,120) as closedate,closetime from oscl where callid = '8'"
;
11.
$objQuery
= mssql_query(
$strSQL
);
12.
while
(
$objResult
= mssql_fetch_array(
$objQuery
))
13.
{
14.
$strDate1
=
$objResult
[
"createdate"
];
15.
$strDate2
=
$objResult
[
"closedate"
];
16.
$strTime1
=
$objResult
[
"createtime"
];
17.
$strTime2
=
$objResult
[
"closetime"
];
18.
19.
echo
$strDate1
.
"<br>"
;
20.
echo
$strDate2
.
"<br>"
;
21.
echo
$strTime1
.
"<br>"
;
22.
echo
$strTime2
.
"<br>"
;
23.
}
24.
?>
25.
<?
26.
function
DateDiff(
$strDate1
,
$strDate2
)
27.
{
28.
return
(
strtotime
(
$strDate2
) -
strtotime
(
$strDate1
))/ ( 60 * 60 * 24 );
29.
}
30.
function
TimeDiff(
$strTime1
,
$strTime2
)
31.
{
32.
return
(
strtotime
(
$strTime2
) -
strtotime
(
$strTime1
))/ ( 60 * 60 );
33.
}
34.
function
DateTimeDiff(
$strDateTime1
,
$strDateTime2
)
35.
{
36.
return
(
strtotime
(
$strDateTime2
) -
strtotime
(
$strDateTime1
))/ ( 60 * 60 );
37.
}
38.
39.
echo
"Date Diff = "
.DateDiff(
$strDate1
,
$strDate2
).
"<br>"
;
40.
echo
"Time Diff = "
.TimeDiff(
$strTime1
,
$strTime2
).
"<br>"
;
41.
echo
"Date Time Diff = "
.DateTimeDiff(
$strDate1
.
$strTime1
,
$strDate2
.
$strTime2
).
"<br>"
;
42.
?>
43.
</body>
44.
</html>