20644

get day of the week from yyyy-mm-dd

Question:

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 ;)

Answer1:

Assuming .NET (from the datetime tag):

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

Answer2:

Since you never told us the language, <a href="http://en.allexperts.com/q/Cobol-1443/2008/6/COBOL-5.htm" rel="nofollow">here</a>'s a discussion on how to do it in COBOL.

Answer3:

In C, you would use a combination of the <a href="http://linux.die.net/man/3/localtime" rel="nofollow">localtime()</a> and <a href="http://linux.die.net/man/3/strftime" rel="nofollow">strftime()</a> functions. They should handle internationalization more or less automatically, if your application is set up for it.

Answer4:

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.

Recommend

  • COBOL COMP-3 number format issue
  • Decode a Binary Coded Decimal
  • How to form XFD from cobol Data
  • and events (INotifyPropertyChanged, specifically)
  • What is the difference between Google Developers Console project and a Google **Play** Developers Co
  • Best style for iterating over a small number of items in Python?
  • Change behaviour of Print button in ReportViewer C#
  • How do I include screenshots of the full page in my serenity report (and not only of the viewport) u
  • Entire JSON into One SQLite Field with Python
  • Ability to use Bootstrap 3 grid system to specify width of select element
  • stop execution in Custom validator if it false
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • Installing libCurl - ruby 1.9.3 .. rails 3.2.12 .. Windows
  • ImportError: cannot import name Pubnub
  • Using MouseListener to select a range of cells in a grid
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • Add dynamic data to line chart from mysql database with highcharts
  • Extract zip entries to another Zip file
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • OOP Javascript - Is “get property” method necessary?
  • ActiveRecord query for a count of new users by day
  • Cancel a live stream “fast motion” catch-up in Flash
  • Get one-time binding to work for ng-if
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Illegal mix of collations for operation for date/time comparison
  • Master page gives error
  • Volley JsonObjectRequest send headers in GET Request
  • Get object from AWS S3 as a stream
  • Cross-Platform Protobuf Serialization
  • Validaiting emails with Net.Mail MailAddress
  • Javascript convert timezone issue
  • Importing jscolor library in angular 2
  • Do I've to free mysql result after storing it?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • apache spark aggregate function using min value
  • Can't mass-assign protected attributes when import data from csv file
  • sending mail using smtp is too slow
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • How can I use threading to 'tick' a timer to be accessed by other threads?