There is no such thing as "Italian time". Time is always
System.DateTime
. If you need to present it in Italian, it's not time, this is string, which has nothing to do with time.
However, if you mean Italian time zone, you need to use the time zone class
System.TimeZoneInfo
, please see:
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx[
^].
[EDIT] I credit the answer by André Kraak who correctly explained it [END EDIT]
If you need a string, keep reading:
You need to use
System.DateTime.ToString(IFormatProvider)
or
ToString(String, IFormatProvider)
to take into account Italian culture. You need to use the instance of
ICultireInfo
as it implements
IFormatProvider
. Please see the code sample here:
http://msdn.microsoft.com/en-us/library/ht77y576.aspx[
^],
http://msdn.microsoft.com/en-us/library/8tfzyc64.aspx[
^].
Of course, put appropriate culture ("it-IT") code instead of "ja-JP".
[EDIT]
Added another method and Italian culture code in the previous two paragraphs, to make it more clear.
You can find a list of culture codes in many documents, for example, here:
http://sharpertutorials.com/list-of-culture-codes/[
^].
For format specifiers, please see:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[
^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[
^].
A format specifier can be used with
IFormatProvider
or without it; and
IFormatProvider
can be used with or without format specifier.
Suppose you need a date-time string in Italian:
System.DateTime time = System.DateTime.Now;
System.IFormatProvider culture = new System.Globalization.CultureInfo("it-IT");
string defaultTimeString = time.ToString(culture);
string fullDateTimePatternShortTime = time.ToString("f", culture);
string fullDateTimePatternLongTime = time.ToString("F", culture);
string fullDayMonthYearOnly = time.ToString("dd MMMM yyyy", culture);
—SA