开发者

Add Current Date/Time to downloaded file in PHP

开发者 https://www.devze.com 2023-03-13 05:03 出处:网络
I have a link that downloads a current database Table, I need to it to have the current date attached at the end of the filename every time?

I have a link that downloads a current database Table, I need to it to have the current date attached at the end of the filename every time?

   header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=CARD_MASTER**DATE HERE**.xls");
    header("Pragma: no-cache开发者_运维技巧");
    header("Expires: 0");
    print "$header\n$data";


header("Content-Disposition: attachment; filename=CARD_MASTER-".date('Y-m-d').".xls");

I just used the Y-m-d format, you can use a different variation by looking into the date() function


You can insert a date in the header, as you would in any string:

header("Content-Disposition: attachment; filename=CARD_MASTER-" . 
    date("m-d-y") . ".xls");
0

精彩评论

暂无评论...
验证码 换一张
取 消