rlv-dan / Snap2HTML

Generates directory listings contained in a single, app-like HTML files
http://www.rlvision.com/snap2html
GNU General Public License v3.0
498 stars 94 forks source link

How do I fill a single-digit date with "0"? #52

Open kidzgy opened 4 months ago

kidzgy commented 4 months ago

6665c7c75e6d1bfa0512be16

For example, 2022/5/2 is displayed as 2022/05/02, so that the dates can be aligned neatly and with the same width.

rlv-dan commented 4 months ago

Find the following function in template.htmland change toLocaleString() to something that suits you better:

function timestampToDate(timestamp){
    // Convert UNIX timestamp to local date
    // If you don't like the date format, try something else, such as toLocaleDateString() manually formatting the date here
    return new Date(timestamp * 1000).toLocaleString();
}