Click here to Skip to main content
13,863,479 members
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 13 Jun 2008
Licenced CPOL

Persian Calendar with Simulated PHP Methods in C#

, 1 Jan 2009
Rate this:
Please Sign up or sign in to vote.
Generate Persian Calendar with simulated PHP methods


I was already using PHP for programming; I was using the following methods for date:

  • time
  • mktime
  • date

Since I'm using C#, I always like to write a class with these methods because usage of these methods is much easier than C# classes (in my opinion). Finally, I wrote this class and you can use it. You can use this library like PHP methods (time, mktime, date).

MohammadDayyanCalendar Methods

  • public uint Time()

    Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

  • public string Date(string Format, double Seconds, bool persianNumbers)
  • Returns a string formatted according to the given format string using the given double second. You can see all supported formats in the Persian document.

  • public int Mktime(int year, int month, int day, int hour, int minute, int second)

    Returns the Unix timestamp corresponding to the arguments given. This time is an integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.

Using the Code

Let's see how we can work with this class.

Add this class to your project references:



Now we can use this DLL in our own project:

public Form1()

    MDCalendar mdCalendar = new MDCalendar();
    DateTime date = DateTime.Now;
    TimeZone time = TimeZone.CurrentTimeZone;
    TimeSpan difference = time.GetUtcOffset(date);
    uint currentTime = mdCalendar.Time() + (uint)difference.TotalSeconds;
    label1.Text = mdCalendar.Date("W D M Y G   ....   d E Z A", currentTime, true);
    label2.Text = mdCalendar.Date("H : i : s", currentTime, true);



  • 14th June, 2008: First post
  • 27th December, 2008: Last update


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


About the Author

Mohammad Dayyan
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
M.Khadem17-Oct-09 1:53
memberM.Khadem17-Oct-09 1:53 
GeneralMy vote of 1 Pin
mheidari22-Jul-09 22:06
membermheidari22-Jul-09 22:06 
GeneralMy vote of 1 Pin
Rob Graham1-Jan-09 14:12
memberRob Graham1-Jan-09 14:12 
Generalpublic uint Time() : Pin
Xaroth15-Jun-08 2:13
memberXaroth15-Jun-08 2:13 
GeneralRe: public uint Time() : Pin
Mohammad Dayyan15-Jun-08 4:33
memberMohammad Dayyan15-Jun-08 4:33 
GeneralRe: public uint Time() : Pin
Rob Graham1-Jan-09 14:07
memberRob Graham1-Jan-09 14:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190214.1 | Last Updated 1 Jan 2009
Article Copyright 2008 by Mohammad Dayyan
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid