Reputation: 7301
I try to convert persian date to standard datetime .The persian date has a format like this :1392/01/23
.
My function :
public DateTime ConvertPeersianToEnglish(string persianDate)
{
string[] formats = { "yyyy/MMMM/dd" };
DateTime d1 = DateTime.ParseExact(persianDate, formats,
CultureInfo.CurrentCulture, DateTimeStyles.None);
return d1;
}
So when i call this function and pass my persian date to it i got an error :
String was not recognized as a valid DateTime.
Why ?
Best regards
Upvotes: 0
Views: 84
Reputation: 27584
Use MM
instead of MMMM
:
string[] formats = { "yyyy/MM/dd" };
MM
is month number 01
to 12
MMMM
is full month name january
to december
(strings depend on culture).
Check out MSDN: Custom date and time format strings
Upvotes: 4