title: PHP - Find file in Directory based on date /YEAR/MONTH/DAY - But not based on current date - static Datestamp
body: <p>I have a variable pulled from a SQL DB which is in the "datetime" format of:</p>
  
  <pre><code>2017-02-22 16:24:12
  </code></pre>
  
  <p>I will be needing to find a file in this directory based on the results of the remaining code, but im not sure how to format the date variables for the directory.</p>
  
  <p>Eg:</p>
  
  <pre><code>/basefolder/2017/02/22/File.extension
  </code></pre>
  
  <p>I have read lots about using date variables, but they are all based on the current date. My thoughts were that I could just strip the numbers like</p>
  
  <pre><code>/basefolder/"first 4 numbers"/"second 2 numbers"/"last 2 numbers"/
  </code></pre>
  
  <p>VS trying to do this with any sort of date/time functions. But perhaps there is a date fuction I can/should use.</p>
  
  <p>I do know that the datetime will always be formatted as such, but it feels "hackish" to do it the first way. I could do it in bash in a second, but I'm not so good w/ PHP.</p>
  
  <p>Thanks for any help!</p>
  
  <p>PS: To give context, I will be getting 2 variables passed to this php script, phone number and date. I will then query the CDR table for the Unique ID of this call record based on that information, then I know the file will be in:</p>
  
  <pre><code>/monitor/2017/02/22/*uniqueID*
  </code></pre>
  
  <p>Which I will then pass back to the original script to have it download the file.</p>