Hi @Mansour_Dalir ,
The PersianCalendar Class document already provide the code that can convert Date
or DateTime
to a Persian Calendar datetime.
Dim pc As New PersianCalendar()
Dim thisDate As Date = Date.Now
' Display the current date using the Gregorian and Persian calendars.
Console.WriteLine("Today in the Gregorian Calendar: {0:dddd}, {0}", thisDate)
Console.WriteLine("Today in the Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate))
Console.WriteLine()
' Create a date using the Gregorian calendar.
thisDate = New DateTime(2013, 5, 28, 10, 35, 0)
Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate)
Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate))
Console.WriteLine()
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.