Trying to create a value to store filename according to date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KeeganWolf
Forum Newbie
Posts: 19
Joined: Thu May 14, 2009 3:13 pm

Trying to create a value to store filename according to date

Post 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?
Last edited by Benjamin on Fri May 15, 2009 10:31 am, edited 1 time in total.
Reason: Added [code=php] tags.
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

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

Post 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';
Last edited by Benjamin on Fri May 15, 2009 11:03 am, edited 1 time in total.
Reason: Changed code type from text to php.
KeeganWolf
Forum Newbie
Posts: 19
Joined: Thu May 14, 2009 3:13 pm

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

Post by KeeganWolf »

Thank you so much!
Post Reply