autoindex_localtime
The `autoindex_localtime` directive enables the display of local time in directory listings.
Description
The autoindex_localtime directive in NGINX affects the way directory listings are generated when directory indexing is enabled. When this directive is set to 'on', NGINX will display the last modified time of files in the local time zone instead of UTC, making it more intuitive for users who may be more familiar with their local time rather than coordinated universal time.
This directive can be placed in several contexts including 'http', 'server', and 'location', allowing for fine-grained control over its behavior based on the scope of the request. The parameter for this directive is simply a flag: 'on' to enable local time display in directory listings or 'off' to disable it, with 'off' being the default state. Enabling this feature can enhance user experience, particularly for applications that involve displaying file metadata in a user-friendly manner, as it allows users to see time formats that are relevant to their geographical location, rather than having to convert from UTC.
It’s important to note that enabling autoindex_localtime does not change the actual timestamps of the files stored on the server; rather, it simply changes how those timestamps are presented in directory listings to end-users.
Config Example
location /files {
autoindex on;
autoindex_localtime on;
}Be sure to enable 'autoindex' directive for the local time display to take effect; otherwise, it will not show any directory listing.
This directive does not apply if directory indexing is disabled. Ensure that 'autoindex' is set to 'on' in order for 'autoindex_localtime' to have any effect.