Since hidden fields are available in any web application so you can embed a hidden field in your page and set its value in server side and use it in client side javascript. so here is a sample ASP.NET solution :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testdate.aspx.cs" Inherits="testdate" %>
<!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></title>
</head>
<body onload="writeServerdDT()">
<script>
function writeServerdDT() {
document.write(document.getElementById('serverDateTime').value);
}
</script>
<form id="form1" runat="server" >
<asp:HiddenField ID="serverDateTime" runat="server"/>
<div>
</div>
</form>
</body>
</html>
and the CodeBehind :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class testdate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
serverDateTime.Value = DateTime.Today.ToString();
}
}
Hope it helps.