Skip to content
Snippets Groups Projects
Commit ebc6c5a5 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Merge in from VM / WC: Provide more date/time variables

parent ffc9c5b2
Branches master
No related tags found
No related merge requests found
...@@ -226,18 +226,33 @@ class OrdernumberHelper { ...@@ -226,18 +226,33 @@ class OrdernumberHelper {
} }
return self::randomString ($alphabet, $len); return self::randomString ($alphabet, $len);
} }
public function getDateTime($utime) {
$time = new DateTime();
$time->setTimestamp($utime);
return $time;
}
public function setupDateTimeReplacements (&$reps, $details, $nrtype) { public function setupDateTimeReplacements (&$reps, $details, $nrtype) {
$utime = microtime(true); $utime = microtime(true);
$reps["[year]"] = date ("Y", $utime); $time = $this->getDateTime($utime);
$reps["[year2]"] = date ("y", $utime); $reps["[year]"] = $time->format ("Y");
$reps["[month]"] = date("m", $utime); $reps["[year2]"] = $time->format ("y");
$reps["[day]"] = date("d", $utime); $reps["[month]"] = $time->format("m");
$reps["[hour]"] = date("H", $utime); $reps["[monthname]"] = $time->format("F");
$reps["[hour12]"] = date("h", $utime); $reps["[monthname3]"] = $time->format("M");
$reps["[ampm]"] = date("a", $utime); $reps["[week]"] = $time->format("W");
$reps["[minute]"] = date("i", $utime); $reps["[weeknumberyear]"] = $time->format("o");
$reps["[second]"] = date("s", $utime); $reps["[day]"] = $time->format("d");
$reps["[dayofyear]"] = $time->format("z")+1;
$reps["[weekday]"] = $time->format("N");
$reps["[weekdayname3]"] = $time->format("D");
$reps["[weekdayname]"] = $time->format("l");
$reps["[hour]"] = $time->format("H");
$reps["[hour12]"] = $time->format("h");
$reps["[ampm]"] = $time->format("a");
$reps["[minute]"] = $time->format("i");
$reps["[second]"] = $time->format("s");
$milliseconds = (int)(1000*($utime - (int)$utime)); $milliseconds = (int)(1000*($utime - (int)$utime));
$millisecondsstring = sprintf('%03d', $milliseconds); $millisecondsstring = sprintf('%03d', $milliseconds);
$reps["[decisecond]"] = $millisecondsstring[0]; $reps["[decisecond]"] = $millisecondsstring[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment