ASP doesn't have the .NET UtcNow() function, but you can easily make one. Code I found on google seemed overly complex for such a simple solution. this lets you get the server UTC time in classic ASP, it outputs the time in datetime format, and the function is conveniently named UtcNow so that if you wanted to transfer your code to asp.net later, it would already be taken care of. make sure you replace the brackets and put the javascript in the head.
[script language="JScript" runat="server"]
var serverdate=new Date();
[/script]
[%
Function UtcNow()
UtcNow = serverdate.toUTCString()
UtcNow = CDate(Replace(Right(UtcNow, Len(UtcNow) - Instr(UtcNow, ",")), "UTC", ""))
End Function
%]
Nice. Mixing JS and VBScript on the server side can be used to create some interesting stuff. Thanks.
ReplyDeleteThank you for posting this - it was a real timesaver.
ReplyDelete