开发者

Add Current Date/Time to downloaded file in PHP

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜