Last active
March 2, 2018 02:36
-
-
Save Llewellynvdm/e13ed45e73590cc4bcd98a73cf9305f1 to your computer and use it in GitHub Desktop.
fancyDate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Change to nice fancy date (change was made) | |
*/ | |
public static function fancyDate($date) | |
{ | |
if (!self::isValidTimeStamp($date)) | |
{ | |
$date = strtotime($date); | |
} | |
return date('jS \o\f F Y',$date); | |
} | |
/** | |
* Change to nice fancy day time and date | |
*/ | |
public static function fancyDayTimeDate($time) | |
{ | |
if (!self::isValidTimeStamp($time)) | |
{ | |
$time = strtotime($time); | |
} | |
return date('D ga jS \o\f F Y',$time); | |
} | |
/** | |
* Change to nice fancy time and date | |
*/ | |
public static function fancyDateTime($time) | |
{ | |
if (!self::isValidTimeStamp($time)) | |
{ | |
$time = strtotime($time); | |
} | |
return date('(G:i) jS \o\f F Y',$time); | |
} | |
/** | |
* Change to nice hour:minutes time | |
*/ | |
public static function fancyTime($time) | |
{ | |
if (!self::isValidTimeStamp($time)) | |
{ | |
$time = strtotime($time); | |
} | |
return date('G:i',$time); | |
} | |
/** | |
* Check if string is a valid time stamp | |
*/ | |
public static function isValidTimeStamp($timestamp) | |
{ | |
return ((int) $timestamp === $timestamp) | |
&& ($timestamp <= PHP_INT_MAX) | |
&& ($timestamp >= ~PHP_INT_MAX); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment