问题
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