Skip to content

Instantly share code, notes, and snippets.

@thedineshj
Created December 6, 2018 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedineshj/09027e1de1a950e90d022e8312ed26dd to your computer and use it in GitHub Desktop.
Save thedineshj/09027e1de1a950e90d022e8312ed26dd to your computer and use it in GitHub Desktop.
PHP-How to create a directory based on current year and current month ?
<?php
// - current year (for example : 2018)
$year=date('Y');
// - current month (for example : 12)
$month=date('m');
// directory path
$directory="./{$year}/{$month}/";
// create directory , if directory doesn't exist
if(!file_exists($directory)){
// creating directory
mkdir($dir,0777, TRUE);
echo "Directory ( {$directory} ) created";
}
// directory already exists
else{
echo "Directory ( {$directory} ) already exists";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment