29 April 2007

Display UTC Time

Display UTC Time


<%@ Page Language="VB" %>

<script runat="server">
Private Sub UpdateTime()

Dim culture As System.Globalization.CultureInfo =
System.Globalization.CultureInfo.GetCultureInfo(1033)
Dim currentDateTime As DateTime = DateTime.UtcNow
Me.DisplayTimeLabel.Text = String.Format(culture, "{1}", Environment.NewLine, _
currentDateTime.ToString("dddd, dd MMMM yyyy, hh:mm", culture))


End Sub

Protected Sub GetUtcTimeButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles GetUtcTimeButton.Click

UpdateTime()
End Sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Display UTC Time</title>
</head>
<body>
<form id="AppMainForm" runat="server">
<div>
<asp:Label ID="DisplayTimeLabel" runat="server"></asp:Label>
<asp:Button ID="GetUtcTimeButton" runat="server" Text="Update" />
<br />
<br />
<asp:Label ID="ErrorLabel" runat="server" ForeColor="Red"></asp:Label>
</div>
</form>
</body>
</html>

No comments: