Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to make a date converter app with c# windows form app.I had use this code but I could use it just for that date.
System.Globalization.PersianCalendar pc;
pc = new System.Globalization.PersianCalendar();
year_label1.Text = pc.GetYear(DateTime.Now).ToString();

Thanks!
Posted
Updated 31-Mar-13 2:52am
v2
Comments
Zoltán Zörgő 31-Mar-13 8:18am    
Please explain this: "Now I wanna give it a date and app changes that"!
It is working with current date, and you want to make it work with user input date - so that user enters a gregorian date and the program shows it's Persian equivalent?
mdhrchi 31-Mar-13 8:46am    
I am sorry for my bad language!
Zoltán Zörgő 31-Mar-13 9:07am    
No problem, but you have not answered.
[no name] 31-Mar-13 8:19am    
Okay so go ahead and do that. Did you maybe have some sort of a question?

1 solution

You may use GetYear on any DateTime:
C#
DateTime dt = new DateTime(2013,1,1);
System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
pc.GetYear(dt);

By the way you may visit following links:
What's Wrong with Persian Culture in .Net[^]

Fixing Optional Calendars for Persian Culture in .NET[^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900