本文介绍了如何将日期时间转换为短日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C#代码将2011-07-24 00:00:00.000转换为07-24-2013(MM-DD-YYYY)。请帮帮我
How can I convert 2011-07-24 00:00:00.000 into 07-24-2013(MM-DD-YYYY) in C# code. Please help me
推荐答案这里的示例使用 C# [ ^ ]& SQL Server [ ^ ] Here samples using C#[^] & SQL Server[^]
尝试执行以下代码 Try to execute below code DateTime thisDate1 = new DateTime(2011, 6, 10); Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + "."); DateTimeOffset thisDate2 = new DateTimeOffset(2011, 6, 10, 15, 24, 16, TimeSpan.Zero); Console.WriteLine("The current date and time: {0:MM/dd/yy H:mm:ss zzz}", thisDate2);
以下单行代码将帮助您解决问题。 。 。 我将今天的日期时间转换为短日期和短时间。 获取当前日期和时间: Following Single line code will help you out . . . I am Converting TODAY'S date time to short date and short time. To get current date and time: DateTime CurrentDateTime = DateTime.Now;
将今天的DateTime转换为短日期:
To Convert today's DateTime to short date:
string CurrentDate= CurrentDateTime.ToShortDateString();将今天的DateTime转换为短时间:
To Convert today's DateTime to short time:
string CurrentTime= CurrentDateTime.ToShortTimeString()
更多推荐
如何将日期时间转换为短日期时间
发布评论