如何插入雨果网站的当前日期短代码
到目前为止,我已经成功地在我的网站上放了一个iframe短代码。
我想做的是将今天的日期放入我拥有日期的iframe
{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date=2022-03-31&type=Daily_CPU" >}}
URL
<iframe src="{{.Get 0}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>
中JavaScript要获得今天的日期:
<script>
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
document.write(today);
</script>
我一直在尝试一只装满东西的手,到目前为止,似乎没有什么正确的。
我认为这在iFrame短码定义中会起作用,但这并不是:
<iframe src="{{.Get 0}}{{< date >}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>
显然我在这里做错了什么。你能帮助我吗?我没有想到一种简单的方法吗?
So far I have successfully put an iframe shortcode on my site.
What I want to do is put today's date into the iframe url where I have the date, like this where I have an old static date:
{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date=2022-03-31&type=Daily_CPU" >}}
Here is my "charts" shortcode definition for the iframe:
<iframe src="{{.Get 0}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>
Here is my "date" shortcode with some javascript to get today's date:
<script>
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
document.write(today);
</script>
I have been trying a hand full of things and nothing seems to work right, so far.
I thought this would have worked in the iframe shortcode definition, but it does not:
<iframe src="{{.Get 0}}{{< date >}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>
Clearly I'm doing something wrong here. Can you help me? Is there an easier way that I'm not thinking of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未经测试,但应该引导您朝正确的方向...
{{&lt; ”&gt;}}}}}}}}
图表“ https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment = dev&amp;date = 2022-03-03-03-31&amp;
type = daily_cpu 图表“ https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment = dev&amp;date = {now.format |“您所需的格式”}}}}}}}
Untested but should lead you in the right direction...
{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date=2022-03-31&type=Daily_CPU" >}}
Becomes:
{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date={{now.Format | "YOUR NEEDED FORMAT HERE"}}&type=Daily_CPU" >}}