Created
December 6, 2018 20:15
-
-
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 ?
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
<?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