gpt4 book ai didi

asp-classic - 使用 VBScript 和 ASP Classic 的服务器时间

转载 作者:行者123 更新时间:2023-12-02 22:37:33 25 4
gpt4 key购买 nike

我创建了一个应用程序来在达到目标日期和时间后显示新闻稿,我想知道这是从服务器还是客户端获取时间,因为我想使用服务器的时间以便有人不只是为了看到它而改变他们的时钟。

这是我的代码:

    <%
dim strDate
dim strTime
dim strTarget_time
dim strTarget_date
dim strBreak
dim strRuleBreak
dim strToday

strDate = Date()
strTime = Time()
strright_now = Now()
strTarget_time = "3:27:00 PM"
strTarget_date = "6/26/2012"
strBreak = "<br />"
strRuleBreak = "<br /><hr><br />"
strToday = Now()

response.write("<h2>TEST VARIABLES</h2>")
response.write("<p><strong>Today's date:</strong> " & strDate & strBreak)
response.write("<strong>Current time:</strong> " & strTime & strBreak)
response.write("<strong>Target date:</strong> " & strTarget_date & strBreak)
response.write("<strong>Target time:</strong> " & strTarget_time & "</p>")
response.write(strRuleBreak)

'TIME TESTER
response.write("<h2>TIME TESTER</h2>")
response.write("<p><nobr>Testing to see if it is past the target time of: " & strTarget_time & "</nobr></p>")
if strTime >= cdate(strTarget_time) then
response.write("<p>Yes, it is now " & Now() & ", which <strong>IS</strong> past the target time of: " & strTarget_time & "</p>")
else
response.write("<p>No, it is now " & Now() & ", which is <strong>NOT</strong> past the target time of: " & strTarget_time & "</p>")
end if

response.write(strRuleBreak)

'DATE TESTER
response.write("<h2>DATE TESTER</h2>")
response.write("<p><nobr>Testing to see if it is past the target date of: " & strTarget_date & "</nobr></p>")
if strToday >= cdate(strTarget_date) then
response.write("<p>Yes, it is now " & Now() & ", which <strong>IS</strong> past the target date of: " & strTarget_date & "</p>")
else
response.write("<p>No, it is now " & Now() & ", which is <strong>NOT</strong> past the target date of: " & strTarget_date & "</p>")

end if
response.write(strRuleBreak)

'DATE AND TIME TESTER
response.write("<h2>DATE AND TIME TESTER</h2>")
response.write("<p><nobr>Testing to see if it is past the target of: " & strTarget_date & "&nbsp;-&nbsp;" & strTarget_time & "</nobr></p>" & strBreak)
if strToday >= cdate(strTarget_date) AND strTime >= cdate(strTarget_time) then
response.write("<p>Yes, it is now " & Now() & ", which <strong>IS</strong> past the target of: " & strTarget_date & "&nbsp;-&nbsp;" & strTarget_time & "</p>")
else
response.write("<p>No, it is now " & Now() & ", which is <strong>NOT</strong> past the target of: " & strTarget_date & "&nbsp;-&nbsp;" & strTarget_time & "</p>")

end if
response.write(strRuleBreak)

%>

所以在这种情况下,如果时间和日期是 AFTER 6/26/2012 3:27 PM,那么该部分将显示。我问的主要是因为我想澄清这是使用客户端还是服务器端时间。

最佳答案

这将是服务器端,因为这是执行 ASP 代码的地方。为了获取客户端日期时间,您需要使用脚本在浏览器中运行 - 通常是 JavaScript。

关于asp-classic - 使用 VBScript 和 ASP Classic 的服务器时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11227565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com