我正在尝试获取服务器时间而不是客户端日期和时间。当我使用这段代码时,它会让我在计算机上更改时间。我想让它只是保持服务器时间。
<script runat="server">
Protected serverTime As DateTime = System.DateTime.Now()
</script>
我在这里用我的asp形式输出
<%= serverTime.ToString()%>
答案 0 :(得分:1)
以下任何一项都有效:
Protected serverTime As String = System.DateTime.Now.ToString();
Protected serverTime As String = System.DateTime.Now.ToLongDateString();
Protected serverTime As String = System.DateTime.Now.ToLongTimeString();
Protected serverTime As String = System.DateTime.Now.ToShortDateString();
Protected serverTime As String = System.DateTime.Now.ToShortTimeString();