Miguel
Miguel

Reputation: 3

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 (make it customizable)

thanks in advance ;)

Upvotes: 0

Views: 742

Answers (4)

unwind
unwind

Reputation: 399833

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.

Upvotes: 1

Mehmet Ergut
Mehmet Ergut

Reputation: 1094

Assuming .NET (from the datetime tag):

DateTime.Parse("2009-10-02").ToString("D", CultureInfo.CreateSpecificCulture("en"));

Upvotes: 2

luvieere
luvieere

Reputation: 37494

Since you never told us the language, here's a discussion on how to do it in COBOL.

Upvotes: 7

Lars D
Lars D

Reputation: 8563

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.

Upvotes: 0

Related Questions