How to get last-modified of the pass that is added by user dynamically

怎甘沉沦 提交于 2019-12-11 16:20:00

问题


Before I had a pass in my server and I got last-modified by using this:
header('Last-Modified: ' . date("D, d M Y H:i:s", filemtime('/Applications/MAMP/htdocs/passesWebserver/DigiClubCard.pkpass')) . ' GMT+07:00'); Now I don't have any pass in my server and I only have data of pass in database, so what should I change this header in order to get last-modified of the pass?


回答1:


If you are sending a new, dynamically created pass, to create a header with the current time you can:

// Tell PHP to use UTC
date_default_timezone_set ('UTC');

// Create a header with the current time
header('Last-Modified: ' . date("D, d M Y H:i:s", time()) . ' GMT');

With regards to the timezone, Section 3.3.1 of the HTTP/1.1 standard RFC2616 states:

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception. For the purposes of HTTP, GMT is exactly equal to UTC (Coordinated Universal Time). This is indicated in the first two formats by the inclusion of "GMT" as the three-letter abbreviation for time zone, and MUST be assumed when reading the asctime format. HTTP-date is case sensitive and MUST NOT include additional LWS beyond that specifically included as SP in the grammar.

so you should not be adding on 7 hours to GMT.



来源:https://stackoverflow.com/questions/16182486/how-to-get-last-modified-of-the-pass-that-is-added-by-user-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!