日期时间并从计算机返回日期 [英] Date Time and return the date from computer
本文介绍了日期时间并从计算机返回日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何返回星期六之类的日期名称来自我的电脑
我使用
DateTime date = new DateTime(DateTime .Now.Date.Day);
MessageBox.Show(date.DayOfWeek.ToString());
但它没有返回正确的日期,当你改变电脑的时间时它会在同一天返回
请帮助
How to return The name of day like "Saturday" From my Computer
I used
DateTime date = new DateTime(DateTime.Now.Date.Day);
MessageBox.Show(date.DayOfWeek.ToString());
but it does not return the correct day and when you change the time in pc it return the same day
please Help
推荐答案
DayOfWeek dtt = DateTime.Now.DayOfWeek ;
MessageBox.Show(dtt.ToString());
以上代码将仅返回您计算机中的当天字符串格式。
Above code will return just the current day in your computer in string format.
在这里查看: http://www.csharp -examples.net/string-format-datetime/ [ ^ ]
Look around here: http://www.csharp-examples.net/string-format-datetime/[^]
String.Format("{0:dddd}", DateTime.Now);
使用System查看以下
see the following
using System;
class Program
{
class Employee
{
public DateTime HiringDate { get; set; }
}
static void Main()
{
//
// Write the current date and time.
//
DateTime now = DateTime.Now;
Console.WriteLine(now);
//
// Store a DateTime in a class.
//
Employee employee = new Employee() { HiringDate = now };
Console.WriteLine(employee.HiringDate);
}
}
这篇关于日期时间并从计算机返回日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文