Jump to content

Getting a filename according to date


KeeganWolf

Recommended Posts

Hi,

 

I just can't seem to figure this out. I have a system that parses information from a zip file according to the store number and date on a daily basis. It's always in the format of e.g. store 5081...

 

S508106142009-06152009.zip

 

Suddenly I have files coming in with 2 days between like.

 

S508106132009-06152009.zip

 

Which my code can't currently handle. This code tends to come out with a weird number for $daybefore

 

$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"));
$daybefore = mktime(0, 0, 0, date("m"), date("d")-2, date("y"));
//		echo "Day before ----> ", $daybefore, "<br />";
//		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<br />";
$prevfile = 'S'.$store.date('md20y', $daybefore).'-'.$yesterday.'.zip';
$filename = 'S'.$store.date('md20y', $yesterday).'-'.$today.'.zip';
//		echo "Previous filename is", $prevfile; 

 

I'm sure theres a better way of doing this, like only getting the newest filename as a value.

 

Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.