12/24 Hour Time format
Current System Datetime or Server Datetime convert to 12/24 Hour format.
Html Coding
// Current Datetime
Demo
Demo
Current System Datetime or Server Datetime convert to 12/24 Hour format.
Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>12/24 Hour Time format Using Asp.Net C#</title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<br />
<asp:Label ID="lblTimeFormat" runat="server" Text="Label"></asp:Label> </div>
</form>
</body>
</html>
C# Coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblTimeFormat.Text = DateTime.Now.ToString();
// 24
hour Time Format
lblTimeFormat.Text = DateTime.Now.ToString("HH:mm");
//// 12
Hour Time Format
lblTimeFormat.Text = DateTime.Now.ToString("hh:mm");
//// 24
Hour with Seconds
lblTimeFormat.Text = DateTime.Now.ToString("HH:mm:ss");
//// 12
Hour with Seconds
lblTimeFormat.Text = DateTime.Now.ToString("hh:mm:ss");
//// 24
Hour with AM or PM
lblTimeFormat.Text = DateTime.Now.ToString("HH:mm:ss tt");
//// 12
Hour with AM or PM
lblTimeFormat.Text = DateTime.Now.ToString("hh:mm:ss tt");
// 24
Hour with Month display
lblTimeFormat.Text = DateTime.Now.ToString("dd/MMM/yyyy HH:mm:ss tt");
// 24
Hour with 3 Character Day display
lblTimeFormat.Text = DateTime.Now.ToString("ddd/MMM/yyyy HH:mm:ss tt");
// 24
Hour with Month & Day display
lblTimeFormat.Text = DateTime.Now.ToString("d/MMM/yyyy HH:mm:ss tt");
// 24
Hour with Full Day display
lblTimeFormat.Text = DateTime.Now.ToString("dddd/MMM/yyyy HH:mm:ss tt");
// 24
Hour with 3 Character Day display
lblTimeFormat.Text = DateTime.Now.ToString("ddd/MMMM/yyyy HH:mm:ss tt");
// 12
Hour with Hour display
lblTimeFormat.Text = DateTime.Now.ToString("dd/MMMM/yyyy h:mm:ss");
// 24
Hour with Hour display
lblTimeFormat.Text = DateTime.Now.ToString("dd/MMMM/yyyy H:mm:ss");
}
}
// Current Datetime
DateTime.Now.ToString();
Demo
// 24 hour Time Format
DateTime.Now.ToString("HH:mm");
//// 12 Hour Time Format
DateTime.Now.ToString("hh:mm");
Demo
//// 24 Hour with Seconds
DateTime.Now.ToString("HH:mm:ss");
Demo
//// 12 Hour with Seconds
DateTime.Now.ToString("hh:mm:ss");
Demo
//// 24 Hour with AM or PM
DateTime.Now.ToString("HH:mm:ss tt");
Demo
//// 12 Hour with AM or PM
DateTime.Now.ToString("hh:mm:ss tt");
Demo
// 24 Hour with Month display
DateTime.Now.ToString("dd/MMM/yyyy HH:mm:ss tt");
Demo
// 24 Hour with 3 Character Day display
DateTime.Now.ToString("ddd/MMM/yyyy HH:mm:ss tt");
Demo
// 24 Hour with Month & Day display
DateTime.Now.ToString("d/MMM/yyyy HH:mm:ss tt");
Demo
// 24 Hour with Full Day display
DateTime.Now.ToString("dddd/MMM/yyyy HH:mm:ss tt");
Demo
// 24 Hour with 3 Character Day display
DateTime.Now.ToString("ddd/MMMM/yyyy HH:mm:ss tt");
Demo
// 12 Hour with Hour display
DateTime.Now.ToString("dd/MMMM/yyyy h:mm:ss");
Demo
// 24 Hour with Hour display
DateTime.Now.ToString("dd/MMMM/yyyy H:mm:ss");
0 comments:
Post a Comment