如何将一个月的第一天作为一周工作日? [英] How to get a first day of a month as a week day?

查看:117
本文介绍了如何将一个月的第一天作为一周工作日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将一个月的第一天作为工作日,例如在2013年1月1日输出应该是星期四。

I want to get a first day of a month as week day, e.g. on 01/January/2013 output should be Thursday.

推荐答案

DateTime类内置了:

The DateTime class has that built in:
DateTime dt = DateTime.ParseExact("01/January/2013", "dd/MMMM/yyyy", CultureInfo.InvariantCulture);
Console.WriteLine(dt.DayOfWeek);

将打印星期二,因为今年1月1日是星期二(不是星期四,因为你的问题说明)

Will Print "Tuesday" since the 1st Jan this year was a Tuesday (not a Thursday as your question states)


30秒的Google链接我在这里



http:// msdn。 microsoft.com/en-us/library/bb762911.aspx [ ^ ]



在发布此处之前使用Google非常有意义,我们不会成为您的互联网搜索引擎。将来在发布之前尝试做一些研究。
30 seconds of Google linked me here

http://msdn.microsoft.com/en-us/library/bb762911.aspx[^]

Using Google before posting here makes a lot of sense, we are not here to be your internet search engine. In future try doing some research before you post.


看看: http://msdn.microsoft.com/de-de/library/system.datetime.dayofweek.aspx [ ^ ]



Take a look: http://msdn.microsoft.com/de-de/library/system.datetime.dayofweek.aspx[^]

// This example demonstrates the DateTime.DayOfWeek property
using System;

class Sample 
{
    public static void Main() 
    {
// Assume the current culture is en-US.
// Create a DateTime for the first of May, 2003.
    DateTime dt = new DateTime(2003, 5, 1);
    Console.WriteLine("Is Thursday the day of the week for {0:d}?: {1}", 
                       dt, dt.DayOfWeek == DayOfWeek.Thursday);
    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);
    }
}
/*
This example produces the following results:

Is Thursday the day of the week for 5/1/2003?: True
The day of the week for 5/1/2003 is Thursday.
*/


这篇关于如何将一个月的第一天作为一周工作日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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