My current date time format for Portuguese is d MMM yyyy
resulted in 1 dez 2017
and I want it to display like this: 1 de dez de 2017
when I format the date like so d de MMM de yyyy
I will get this 1 1e dez 1e 2017
is there a way to bypass the de
to be transformed to date?
my question is there a way to format the date like this 1 de dez de 2017
?
new DateTime(2017, 1, 1).ToString("d 'de' MMM 'de' yyyy", new CultureInfo("PT-pt"));
DateTime
s are formatted with custom format specifiers .
You can make sure characters aren't formatted as part of the date/time by escaping them.
There are two methods of escaping characters:
\\
character can be used to escape a single character '
or "
characters can be use to escape a string of characters. The latter is probably easier to use as you can wrap any words in your format string in them and forget about it.
eg:
DateTime.Now.ToString("d 'de' MMM 'de' yyyy");
The d
in de
has a special meaning, so you have to escape that letter with a backslash.
This concerns all letters that might conflict with an already predefined date or time format specifier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.