HTML显示当前日期

编程入门 行业动态 更新时间:2024-10-25 02:23:57
本文介绍了HTML显示当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用名为"clickfunnels"的网站构建器,但它们不支持允许我显示当前日期的功能.但是,我可以向其中添加自定义html.

I am using website builder called 'clickfunnels', and they don't support feature that would allow me to display current date. But, I can add custom html to it.

我想知道是否有人知道如何以dd/mm/yyyy格式显示网站当前日期

I was wondering if anyone knows how to show on website current date in format: dd/mm/yyyy

目前我已经尝试过:

<p id="date"></p> <script> document.getElementById("date").innerHTML = Date(); </script>

这可行,但是它显示的日期是这样的:

And this works, but it displays date likes this:

2015年9月12日星期六格林尼治标准时间+0200(时区....)

Sat Sep 12 2015 16:40:10 GMT+0200 (Timezone.... )

推荐答案

这是一种方法.您必须从日期对象(日,月和年)中获取各个组件,然后根据需要构建并设置字符串格式.

Here's one way. You have to get the individual components from the date object (day, month & year) and then build and format the string however you wish.

n = new Date(); y = n.getFullYear(); m = n.getMonth() + 1; d = n.getDate(); document.getElementById("date").innerHTML = m + "/" + d + "/" + y;

<p id="date"></p>

更多推荐

HTML显示当前日期

本文发布于:2023-10-31 07:19:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!