Use date.lib.php functions
This commit is contained in:
parent
9d1fc28eba
commit
4ef2644300
@ -393,20 +393,20 @@ if (empty($reshook) && $action == 'add')
|
||||
$actionCommReminder = new ActionCommReminder($db);
|
||||
|
||||
if($offsetunit == 'minute'){
|
||||
$dateremind = strtotime("-".$offsetvalue." minutes", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i');
|
||||
} elseif($offsetunit == 'hour'){
|
||||
$dateremind = strtotime("-".$offsetvalue." hours", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h');
|
||||
} elseif ($offsetunit == 'day') {
|
||||
$dateremind = strtotime("-".$offsetvalue." day", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd');
|
||||
} elseif ($offsetunit == 'week') {
|
||||
$dateremind = strtotime("-".$offsetvalue." week", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w');
|
||||
} elseif ($offsetunit == 'month') {
|
||||
$dateremind = strtotime("-".$offsetvalue." month", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm');
|
||||
} elseif ($offsetunit == 'year') {
|
||||
$dateremind = strtotime("-".$offsetvalue." year", $datep);
|
||||
$dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y');
|
||||
}
|
||||
|
||||
$actionCommReminder->dateremind = date('Y-m-d H:i:s', $dateremind);
|
||||
$actionCommReminder->dateremind = $db->idate($dateremind);
|
||||
$actionCommReminder->typeremind = $remindertype;
|
||||
$actionCommReminder->fk_user = $user;
|
||||
$actionCommReminder->offsetunit = $offsetunit;
|
||||
|
||||
@ -108,7 +108,7 @@ function getServerTimeZoneInt($refgmtdate = 'now')
|
||||
*
|
||||
* @param int $time Date timestamp (or string with format YYYY-MM-DD)
|
||||
* @param int $duration_value Value of delay to add
|
||||
* @param int $duration_unit Unit of added delay (d, m, y, w, h)
|
||||
* @param int $duration_unit Unit of added delay (d, m, y, w, h, i)
|
||||
* @return int New timestamp
|
||||
*/
|
||||
function dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
@ -116,6 +116,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
global $conf;
|
||||
|
||||
if ($duration_value == 0) return $time;
|
||||
if ($duration_unit == 'i') return $time + (60 * $duration_value);
|
||||
if ($duration_unit == 'h') return $time + (3600 * $duration_value);
|
||||
if ($duration_unit == 'w') return $time + (3600 * 24 * 7 * $duration_value);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user