Page 1 of 1

Trying to create a value to store filename according to date

Posted: Fri May 15, 2009 10:19 am
by KeeganWolf
Some help for a beginner in php?
I'm trying to get a file name of an automatically created zip and store that name according to the date as a value to work with it. Heres what I have...

Code: Select all

 
<?php
$store = 4071;
$today = date("md20y");
     echo "Today is ",$today, "<br />";
$tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("y"));
     echo "Tomorrow is ".date("md20y", $tomorrow),"<br />";
$yesterday = mktime(0, 0, 0, date("m"), date("d")-1, date("y"));
     echo "Yesterday was ".date("md20y", $yesterday),"<br />";
         echo "Your store number is ",$store, "<br />";
         echo "Your store's filename will be S", $store,"".date("md20y", $yesterday), "-", $today, ".zip";
 ?>
 
It will print the correct filename according to the date as a result
e.g. S407105132009-05142009.zip
But I need to built an unzip function with this script to unzip that file after getting the filename.
How can I make a value $filename from the result of that?

Re: Trying to create a value to store filename according to date

Posted: Fri May 15, 2009 10:56 am
by ldougherty
Using the code you already have in place you can generate the variable as such.

Code: Select all

$filename = 'S'.$store.date('md20y', $yesterday).'-'.$today.'.zip';
If you didn't want to use the variables you had set you could combine it al as such.

Code: Select all

$filename = 'S4071'.date('md20y', mktime(0, 0, 0, date("m"), date("d")-1, date("y"))).'-'.date("md20y").'.zip';

Re: Trying to create a value to store filename according to date

Posted: Fri May 15, 2009 11:25 am
by KeeganWolf
Thank you so much!