Augury Posted March 8, 2014 Share Posted March 8, 2014 It's got two basic features. First it produces an array to be array_merged prior to mysql entry. The time is sort worthy as is (year in front ... last seconds). 100% collation friendly. Second it prints the time in the conventional manor so that your reports are not criticized by all. You can alter the thing to you choice of display formating if you like other wise you have to specify a format (hopefully you have a list of preferred formats already made up). The print will also accept an appropriately formated input, this I've set to the mysql timestamps format. http://CampKojak.com/Time.php I tried to make it look nice. class Time { public static function now ($zone = NULL) { $format = '%Y-%m-%d %H:%M:%S'; $strf = strftime($format); if(isset($zone)) $zone = " " . $zone; $strf .= $zone; return $strf; } public static function Stamp ($zone = NULL) { $timestamp = array("timestamp" => self::now($zone)); return $timestamp; } public static function PPrint ($zone = NULL, $stamp = NULL, $formatin = "Y-m-d H:i:s T", $formatout = "g:i a l n/j/Y") { if(empty($zone)) {$zone = date_default_timezone_get();} if(empty($stamp)) {$stamp = self::Stamp($zone);} $adate = DateTime::createFromFormat($formatin, $stamp["timestamp"]); $dateout = $adate->format($formatout); echo $dateout; return $dateout; } }//END CLASS Quote Link to comment https://forums.phpfreaks.com/topic/286807-timestamp-class-i-wrote/ Share on other sites More sharing options...
Augury Posted March 8, 2014 Author Share Posted March 8, 2014 I used Time::PPrint() which is ugly. The `print` verbage the PHP language has reserved for itself. Quote Link to comment https://forums.phpfreaks.com/topic/286807-timestamp-class-i-wrote/#findComment-1471822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.