Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script runat="server">
void Page_Load()
{
lblServerTime.Text = DateTime.Now.ToString();
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent" Runat="Server">
<div>
The current date and time is:
<asp:Label
ID="lblServerTime"
runat="server" />
</div>
</asp:Content>


What I have tried:

I have tried code behind and a link to display the date and time put it shows parser error:
Line 1:  <%@ Page Title="" Language="C#" MasterPageFile="~/usermaster.Master" AutoEventWireup="true" CodeBehind="datetimeex1.aspx.cs" Inherits="bse21aftmoviestore.tutorials.week2.datetimeex1" %>
Line 2:  
Line 3:  <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
Posted
Comments
Richard MacCutchan 3-Sep-22 3:44am    
What happens if the user is in a different timezone from the server?
fab joey Thibaut 3-Sep-22 4:44am    
It gives only Mauritius time.
fab joey Thibaut 3-Sep-22 4:51am    
It can be also other countries

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900