简体   繁体   中英

How can I dynamically make folder with today's date?

Is it possible and if it is, how can I create automatically folders that have the names of the current date? I read that mkdir() will make me do the folders but how exactly to set the name of these folders so when I get information from some link the folder where i have to save this .txt file to be created with for example - name: 'May-21-2014' (the current date).

The first input of mkdir() is the name . Just put the string of the date into the value you pass it:

$name=date("l");
makdir($name//etc)

would result in a folder called Monday .

Just format the date as you want it.

I would suggest folders to be yyyymmdd - eg 20140522 for today, it makes them sort nicely in ascending date order in a normal directory browser.

This would be:

$name=date('Ymd');

when you make the folder name.

mkdir(strftime("%B %d %Y, %X %Z",mktime(20,0,0,12,31,98)),0777,true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM