HTML how do I insert dynamic date in webpage

前端 未结 8 2108
暖寄归人
暖寄归人 2021-01-05 14:40

I have a static webpage, nothing changes dynamically. However the client wants a date insert into text within the page. The date will always be the current daet plus one day

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 15:19

    Downvoters: Note that the tag "javascript" was added after this answer was given.

    You could use Server Side Includes (SSI), if your server supports them.

    If your server is Apache, you could, for example, put the following element into your HTML page to output a current date + 1 day:

    
    

    Assuming today is 2011-02-05, you'll have the following output on your page in browser:

    ...
    DATE: 2011-02-06
    ...
    

    To output the full weekday name, you can use date -v +1d '+DATE: %A %d, %Y', which gives you DATE: Sunday 06, 2011.


    Further reading:

    • article Server Side Includes at Wikipedia
    • Apache Tutorial: Introduction to Server Side Includes
    • date(1) manual page at FreeBSD.org

提交回复
热议问题