Database: factorized jdate()
This commit is contained in:
parent
1d268c2e86
commit
eb86abff94
@ -64,8 +64,6 @@ abstract class DoliDB implements Database
|
|||||||
public $ok;
|
public $ok;
|
||||||
public $error;
|
public $error;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define sort criteria of request
|
* Define sort criteria of request
|
||||||
*
|
*
|
||||||
@ -94,5 +92,22 @@ abstract class DoliDB implements Database
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
||||||
|
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
||||||
|
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
||||||
|
*
|
||||||
|
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
||||||
|
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
||||||
|
* @return date Date TMS
|
||||||
|
*/
|
||||||
|
function jdate($string, $gm=false)
|
||||||
|
{
|
||||||
|
$string=preg_replace('/([^0-9])/i','',$string);
|
||||||
|
$tmp=$string.'000000';
|
||||||
|
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -553,23 +553,6 @@ class DoliDBMssql extends DoliDB
|
|||||||
return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
|
return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
|
||||||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
|
||||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
|
||||||
*
|
|
||||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
|
||||||
* @return date Date TMS
|
|
||||||
*/
|
|
||||||
function jdate($string, $gm=false)
|
|
||||||
{
|
|
||||||
$string=preg_replace('/([^0-9])/i','',$string);
|
|
||||||
$tmp=$string.'000000';
|
|
||||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a SQL IF
|
* Format a SQL IF
|
||||||
*
|
*
|
||||||
|
|||||||
@ -531,23 +531,6 @@ class DoliDBMysql extends DoliDB
|
|||||||
return dol_print_date($param,"%Y%m%d%H%M%S");
|
return dol_print_date($param,"%Y%m%d%H%M%S");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
|
||||||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
|
||||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
|
||||||
*
|
|
||||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
|
||||||
* @return date Date TMS
|
|
||||||
*/
|
|
||||||
function jdate($string, $gm=false)
|
|
||||||
{
|
|
||||||
$string=preg_replace('/([^0-9])/i','',$string);
|
|
||||||
$tmp=$string.'000000';
|
|
||||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a SQL IF
|
* Format a SQL IF
|
||||||
*
|
*
|
||||||
|
|||||||
@ -541,23 +541,6 @@ class DoliDBMysqli extends DoliDB
|
|||||||
return dol_print_date($param,"%Y%m%d%H%M%S");
|
return dol_print_date($param,"%Y%m%d%H%M%S");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
|
||||||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
|
||||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
|
||||||
*
|
|
||||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
|
||||||
* @return date Date TMS
|
|
||||||
*/
|
|
||||||
function jdate($string, $gm=false)
|
|
||||||
{
|
|
||||||
$string=preg_replace('/([^0-9])/i','',$string);
|
|
||||||
$tmp=$string.'000000';
|
|
||||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a SQL IF
|
* Format a SQL IF
|
||||||
*
|
*
|
||||||
|
|||||||
@ -752,23 +752,6 @@ class DoliDBPgsql extends DoliDB
|
|||||||
return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
|
return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
|
||||||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
|
||||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
|
||||||
*
|
|
||||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
|
||||||
* @return date Date TMS
|
|
||||||
*/
|
|
||||||
function jdate($string, $gm=false)
|
|
||||||
{
|
|
||||||
$string=preg_replace('/([^0-9])/i','',$string);
|
|
||||||
$tmp=$string.'000000';
|
|
||||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a SQL IF
|
* Format a SQL IF
|
||||||
*
|
*
|
||||||
|
|||||||
@ -674,24 +674,6 @@ class DoliDBSqlite extends DoliDB
|
|||||||
return dol_print_date($param,"%Y%m%d%H%M%S");
|
return dol_print_date($param,"%Y%m%d%H%M%S");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
|
|
||||||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
|
||||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
|
||||||
*
|
|
||||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
|
||||||
* @return date Date TMS
|
|
||||||
*/
|
|
||||||
function jdate($string, $gm=false)
|
|
||||||
{
|
|
||||||
$string=preg_replace('/([^0-9])/i','',$string);
|
|
||||||
$tmp=$string.'000000';
|
|
||||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a SQL IF
|
* Format a SQL IF
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user