note 66906 deleted from function.microtime by bjori

From: Date: Thu, 01 Jun 2006 00:53:48 +0000
Subject: note 66906 deleted from function.microtime by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-112695@lists.php.net to get a copy of this message
Note Submitter: geoff at hoffmans dot net Reason: 1 ---- If you're looking for a high-precision timestamp, that is, a string that is formatted like yyyymmddhhiissxxxxxx where xxxxxx is the microsecond portion appended to a standard time stamp, here you go. This is great for renaming uploaded files. <?php function highprecisiontimestamp($l=20){ // returns a date-time-stamp-style string like so: // 20060531144559827180 // This would be for May 31, 2006 at 2:45:59 pm // (plus roughly .827 of a second, give or take) // if you pass in 14 for the length param, the function // returns a standard (mysql) datetimestamp. list($usec, $sec) = explode(" ", microtime()); $microsec = substr($usec,2,6); $rv = date("YmdHis",time()) . $microsec; return substr($rv,0,$l); } ?>

« previous php.notes (#112695) next »