2603.0 - First effort...
This commit is contained in:
60
functions.php
Normal file
60
functions.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
function print_datetime($datestring){
|
||||
$display_datetime=substr($datestring,0,4)."/".substr($datestring,4,2)."/".substr($datestring,6,2)." ".substr($datestring,8,2).":".substr($datestring,10,2).":".substr($datestring,12,2);
|
||||
return $display_datetime;
|
||||
}
|
||||
|
||||
function extract_date($datestring){
|
||||
$dateonly=substr($datestring,0,4)."/".substr($datestring,4,2)."/".substr($datestring,6,2);
|
||||
return $dateonly;
|
||||
}
|
||||
|
||||
function datedigits($datestring){
|
||||
$datedig=substr($datestring,0,8);
|
||||
return $datedig;
|
||||
}
|
||||
|
||||
function extract_time($datestring){
|
||||
$timeonly=substr($datestring,8,2).":".substr($datestring,10,2).":".substr($datestring,12,2);
|
||||
return $timeonly;
|
||||
}
|
||||
|
||||
function timedigits($datestring){
|
||||
$timedig=substr($datestring,8,14);
|
||||
return $timedig;
|
||||
}
|
||||
|
||||
function add_days($datestring,$no_of_days){
|
||||
$datedig=datedigits($datestring);
|
||||
$timedig=timedigits($datestring);
|
||||
$newdate=date('Ymd',strtotime($datedig.' + '.$no_of_days.' days')).$timedig;
|
||||
return $newdate;
|
||||
}
|
||||
|
||||
function add_months($datestring,$no_of_month){
|
||||
$datedig=datedigits($datestring);
|
||||
$timedig=timedigits($datestring);
|
||||
$newdate=date('Ymd',strtotime($datedig.' + '.$no_of_month.' month')).$timedig;
|
||||
return $newdate;
|
||||
}
|
||||
|
||||
function add_years($datestring,$no_of_yrs){
|
||||
$datedig=datedigits($datestring);
|
||||
$timedig=timedigits($datestring);
|
||||
$newdate=date('Ymd',strtotime($datedig.' + '.$no_of_yrs.' year')).$timedig;
|
||||
return $newdate;
|
||||
}
|
||||
|
||||
function datetodigits($formdate){
|
||||
$alldigits=array("0","1","2","3","4","5","6","7","8","9");
|
||||
$length=strlen($formdate);
|
||||
$digitdate="";
|
||||
for($i=0;$i<$length;$i++){
|
||||
$digit=substr($formdate,$i,1);
|
||||
if (in_array($digit,$alldigits)){
|
||||
$digitdate=$digitdate.$digit;
|
||||
}
|
||||
}
|
||||
return $digitdate;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user