I'm trying to format a date to look this way: "day mm/dd/yyyy" for that I'm using something like :
"dddd, " + dateFormatInfo.ShortDatePattern
The thing is ShortDatePattern
does seem to be specific to the current culture info. for example I'm getting:
fr_FR : Lundi 27/06/2011
gb_GB : Monday 27/06/2011 when it should be Monday 06/27/2011
I hope I'm being clear.
[Update] I wanted the string to update automatically between "dd/mm/yyyy" and "mm/dd/yyyy" depending on the current culture and i thought ShortDatePattern didn't do the trick but it actually does! it's just that in en_GB it's still "dd/mm/yyyy" [/update]
[Resolved]
DateTime date;
date.ToString("dddd, " + CurrentCultureInfo.DateTimeFormat.ShortDatePattern);
First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.
To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.
Overview of date and time formats The dates appear as, mm/dd/yyyy in the U.S. and as, dd/mm/yyyy outside the U.S. where mm is the month, dd is the day, and yyyy is the year. The time is displayed as, hh:mm:ss AM/PM, where hh is the hour, mm is minutes, and ss is seconds.
Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.
If you always want the date pattern to be MM/dd/yyyy
, then specify that:
string format = "dddd, MM/dd/yyyy";
Note that the "/" part is also locale-specific; if you want it to always be a forward-slash, you should escape it:
string format = "dddd, MM'/'dd'/'yyyy";
If that's not what you were looking for, please update your question to make it clear exactly what you're doing (with sample code), the result you're getting, and the result you want.
You can use the following:
DateTime date;
date.ToString("dddd, MM/dd/yyyy");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With