get day of the week from yyyy-mm-dd
I would like to convert a yyyy-mm-dd to something like this:
"Saturday, 2 October 2009"
I would like also to have the option to modify the language both day of the week and month (ma开发者_JS百科ke it customizable)
thanks in advance ;)
Since you never told us the language, here's a discussion on how to do it in COBOL.
Assuming .NET (from the datetime tag):
DateTime.Parse("2009-10-02").ToString("D", CultureInfo.CreateSpecificCulture("en"));
In C, you would use a combination of the localtime()
and strftime()
functions. They should handle internationalization more or less automatically, if your application is set up for it.
Convert the date into an integer, representing the days since a specific date, then add a number and apply the modulus operator with the operand 7. That will give you a number 0-6 that represents the day of week.
However, most languages have this functionality built-in.
精彩评论