Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mkdir - Why is this an invalid argument?

Tags:

date

php

mkdir

I wanted to experiment with creating directories titled with the date and current time. I know I can use the php time() function, but that is hard for me to read. Why can't I create a directory named 06-11-2014 11:37:04 or so? The php mkdir function is giving me an invalid argument when I try to use this format.

php code

<?php
$newdate = date("m-d-Y H:i:s");

mkdir($newdate, 0755, true);

?>
like image 231
wheatfairies Avatar asked Dec 20 '22 14:12

wheatfairies


1 Answers

The colons in the date are messing it up. Your best bet is to use a format like this:

$newdate = date("m-d-Y H_i_s");
like image 71
Dan Sharpe Avatar answered Dec 29 '22 16:12

Dan Sharpe