在Winform中使用日期时间 [英] Working with datetime in winform

查看:322
本文介绍了在Winform中使用日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
有人可以将我链接到有关日期时间的文章,还是可以为我提供有关日期时间减法的解决方案,以获取年龄,如何获取当前日期,如何获取当前月份,如何获取当前星期等等,等等

Hi friends
can someone link me to an article that talks about datetime, or provide solution for me on datetime substraction to get age, how to get the current day, how to get the current month,how to get the current week, an so on

推荐答案

请参阅以下文章:
http://www.codeproject.com/KB/datetime/ [
See these articles:
http://www.codeproject.com/KB/datetime/[^]
There is more than enough information for you to learn everything about that topic.
For example to get the age:
DateTime bday = new DateTime(1980, 11, 8);
  DateTime now = DateTime.Today;
  int age = now.Year - bday.Year;
  if (bday > now.AddYears(-age)) age--;

  MessageBox.Show("Age is: "  + age.ToString());


要获得今天:


To get today:

MessageBox.Show("Today is: "  + DateTime.Now.ToShortDateString());
MessageBox.Show("Today is: " + DateTime.Now.ToShortDateString());
MessageBox.Show("Todays day is: " + DateTime.Now.Day.ToString());
MessageBox.Show("Todays month is: " + DateTime.Now.Month.ToString());
MessageBox.Show("Todays year is: " + DateTime.Now.Year.ToString());
MessageBox.Show("Todays weekday is: " + DateTime.Now.DayOfWeek.ToString());


好吧,您本可以用谷歌搜索它们,但是这里有一些:
http://www.java2s.com/Tutorial/CSharp/0260__Date-Time/0020__DateTime.htm [ ^ ]
http://www.geekpedia.com/tutorial98_Using-the-DateTime-object.html [ ^ ]
http://www.dotnetperls.com/datetime [
Well, you could have googled for them yourself, but here are some:
http://www.java2s.com/Tutorial/CSharp/0260__Date-Time/0020__DateTime.htm[^]
http://www.geekpedia.com/tutorial98_Using-the-DateTime-object.html[^]
http://www.dotnetperls.com/datetime[^]


这篇关于在Winform中使用日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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