17 lines
410 B
PHP
17 lines
410 B
PHP
<?php
|
|
|
|
function ensure($bool, $error_msg = "") {
|
|
if (!$bool)
|
|
throw new AssertionError($error_msg);
|
|
}
|
|
|
|
function formatDate($date = NULL, $with_time = false) {
|
|
if ($date == NULL)
|
|
$date = date("yyyy-mm-dd");
|
|
|
|
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
|
|
}
|
|
|
|
function dateWellFormed($date, $format = "yyyy-mm-dd") {
|
|
return date_parse_from_format($format, $date) !== false;
|
|
} |