Created
November 23, 2013 06:03
-
-
Save phpmaps/7611348 to your computer and use it in GitHub Desktop.
PHP helpers
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
public function makeDirectory($dir, $mode = 0666) //Not implemented. | |
{ | |
if (is_dir($dir) || @mkdir($dir,$mode)) return true; | |
if (!$this->makeDirectory(dirname($dir),$mode)) return false; | |
return @mkdir($dir,$mode); | |
} | |
public function rewindDate($date,$days,$minutes) | |
{ | |
$i = 'P'.$days.'D'.'T'.$minutes.'M'; //change S to M for production | |
$date->getTimestamp(); | |
$di = new DateInterval($i); | |
$date->sub($di); | |
return $date; | |
} | |
public function currentDateTime() | |
{ | |
$date = new DateTime(); | |
$date->getTimestamp(); | |
return $date; | |
} | |
public function formatDate($date, $type) | |
{ | |
if($type == "sqlite") | |
{ | |
$f = $date->format('Y-m-d H:i:s'); //HH:MM:SS.SSS | |
}else if ($type == "unix") | |
{ | |
$f = $date->format('U'); | |
} | |
return $f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment