';
for ($i = 1; $i <= 31; $i++) {
$day .= '';
}
$day .= ' ';
$monthNumber = ' ';
$monthName = ' ';
$year = ' ';
$t = str_replace(array('j', 'd', 'F', 'm', 'Y'), array('@@j@@', '@@d@@', '@@F@@', '@@m@@', '@@Y@@'), $format);
return str_replace(array('@@j@@', '@@d@@', '@@F@@', '@@m@@', '@@Y@@'),
array($day, $day, $monthName, $monthNumber, $year), $t);
}
public static function convertToTimeString($s)
{
$h = floor($s / 3600);
$s -= $h * 3600;
$m = floor($s / 60);
$s -= $m * 60;
return sprintf("%02d:%02d:%02d", $h, $m, $s);
}
public static function convertPHPDateFormatToJS($format)
{
$symbolsConvert = array(
// day
'd' => 'dd',
'D' => 'D',
'j' => 'd',
'l' => 'DD',
'N' => '',
'S' => '',
'w' => '',
'z' => 'o',
// week
'W' => '',
// month
'F' => 'MM',
'm' => 'mm',
'M' => 'M',
'n' => 'm',
't' => '',
// year
'L' => '',
'o' => '',
'Y' => 'yy',
'y' => 'y',
// time
'a' => '',
'A' => '',
'B' => '',
'g' => '',
'G' => '',
'h' => '',
'H' => '',
'i' => '',
's' => '',
'u' => ''
);
$jsFormat = '';
$esc = false;
for ($i = 0, $len = strlen($format); $i < $len; $i++) {
$c = $format[$i];
//escaping
if ($c === '\\') {
$i++;
$c = $format[$c];
$jsFormat .= $esc ? $c : '\'' . $c;
$esc = true;
} else {
if ($esc) {
$jsFormat .= "'";
$esc = false;
}
$jsFormat .= isset($symbolsConvert[$c]) ? $symbolsConvert[$c] : $c;
}
}
return $jsFormat;
}
}