Skip to content

Instantly share code, notes, and snippets.

@paulslugocki
Created July 26, 2012 10:28
Show Gist options
  • Save paulslugocki/3181391 to your computer and use it in GitHub Desktop.
Save paulslugocki/3181391 to your computer and use it in GitHub Desktop.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
// DateTime testing
String timeString = "dd/MMM/yyyy H:mm:ss";
// Local time
DateTime testDateTime = DateTime.Now;
Response.Write(testDateTime.ToString(timeString + " z") + "<br>");
// UTC time
DateTime testUtcDatetime = testDateTime.ToUniversalTime();
Response.Write(testUtcDatetime.ToString(timeString) + "<br>");
// Timestamp
TimeSpan span = (testUtcDatetime - new DateTime(1970, 1, 1, 0, 0, 0, 0));
int stamp = (int)span.TotalSeconds;
Response.Write(stamp);
// End DateTime testing
%>
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment