在标签上显示时间 [英] Display time on label

查看:169
本文介绍了在标签上显示时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想在标签上显示当前系统时间24小时后的时间
我正在使用C#visual studio 2008在Asp.net中工作
请指导我如何建立这种逻辑?

解决方案

请看以下内容;

newDate = System.DateTime.Now.AddHours(24);

另外,请查看上述类中可用的其他格式化格式方法.


System.DateTime.Now.AddHours(24).ToString("MM/dd/yyyy");
Or
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy");
Or
System.DateTime.Now.Date.Add(TimeSpan.FromDays(1)).ToString("MM/dd/yyyy");


hii


请尝试:-


第1步:-以我的情况,以我的形式填写Label(Label1)

步骤2:-在Page_Load上编写以下代码:-

受保护的void Page_Load(对象发送者,EventArgs e)
{
Label1.Text = System.DateTime.Now.AddHours(24).ToShortTimeString();
}


hi I want to display a time on label which is of after 24 hours of the current system time
I am working in Asp.net Using C# visual studio 2008
please guide me how to build this logic?

解决方案

Look at the following;

newDate = System.DateTime.Now.AddHours(24);

Also, look at the other methods available in the above classes for formatting etc.


System.DateTime.Now.AddHours(24).ToString("MM/dd/yyyy");
Or
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy");
Or
System.DateTime.Now.Date.Add(TimeSpan.FromDays(1)).ToString("MM/dd/yyyy");


hii


Please Try this:-


Step1:- In my case,take a Label(Label1) in my form

Step 2:- Write the following code on the Page_Load:-

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text=System.DateTime.Now.AddHours(24).ToShortTimeString();
}


这篇关于在标签上显示时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆