Click here to Skip to main content
Click here to Skip to main content

Persian Calendar and Date Picker for Web Applications (JavaScript)

By , 27 Nov 2007
 

Sample Image - Persian_Date_Picker.jpg

Introduction

The Persian Calendar is used in most countries where Persian is spoken, although some regions use different month names. The Persian calendar is the official calendar of Iran and Afghanistan, and is one of the alternative calendars in regions such as Kazakhstan and Tajikistan. The Persian calendar is based on a solar year, and is approximately 365 days long. A year cycles through four seasons, and a new year begins when the sun appears to cross the equator from the southern hemisphere to the northern hemisphere as viewed from the center of the Earth. The new year marks the first day of the month of Farvardin, which is the first day of spring in the northern hemisphere. Each of the first six months in the Persian calendar has 31 days, each of the next five months has 30 days, and the last month has 29 days in a common year and 30 days in a leap year. A leap year is a year that, when divided by 33, has a remainder of 1, 5, 9, 13, 17, 22, 26, or 30. For example, the year 1370 is a leap year because dividing it by 33 yields a remainder of 17. There are approximately 8 leap years in every 33-year cycle.

Using the code

This example demonstrates how to use the Persian Calendar. You should add the required references to the head section of your page:

<script type="text/javascript" language="JavaScript" src="JScripts/amin.js">
</script>
<script type="text/javascript" language="JavaScript" src="JScripts/calendar.js">
</script>
<link rel="stylesheet" type="text/css" href="CSS/calendar.css">

And call the 'displayDatePicker' function where you want the calendar to appear:

<form style="text-align:center ">
  <input name="AnotherDate">
  <input value="select" onclick="displayDatePicker('AnotherDate', this);" type="button">
</form>

License

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

About the Author

Amin Habibi S.
Web Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
Member
I was born in Gonabad (1984).
I spent there my whole life until I was accepted in national university entrance exam. Then I migrated to Tehran.
Now I live in Tehran
 
You can see my CV at: http://habibiamin.googlepages.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberArash Farahani1 Apr '13 - 4:54 
Questionسلامmemberabollfazl9 Jan '13 - 22:36 
Generalمرسیmembere.rabiei6825 Aug '12 - 19:52 
Questiontanksmembers_ahmadneya18 Feb '12 - 3:01 
Questionwow this nicememberjavad1121184 Feb '12 - 1:58 
Questiontnxmemberqazale7 Sep '11 - 3:33 
Questionthanksmembercomputec_teh2 Jul '11 - 0:15 
Generalthxmembernasrin647 Jun '11 - 20:14 
GeneralMy vote of 5memberMohammad Dayyan5 Jun '11 - 4:14 
GeneraljsfmemberMorteza Davoodi1 Jun '11 - 1:17 
GeneralMy vote of 5memberShahin Khorshidnia3 Apr '11 - 18:36 
GeneralPersianCalendar conflictmemberM.M.Rezaee23 Sep '10 - 10:01 
GeneralMy vote of 5membergh_shahabi8 Aug '10 - 3:06 
GeneralpersianCanelndarmembercamelia11125 Jul '10 - 0:21 
GeneralNice work.memberReza Jahanbakhshi21 Apr '10 - 18:31 
Generalسلامmemberali_mahdi29 Sep '09 - 5:43 
GeneralHimemberali_mahdi29 Sep '09 - 5:38 
QuestionHow can i prevent user to modify the choosen date from date picker?memberhoney.hv13 Jul '09 - 2:13 
GeneralGreat work but bad js codememberarash alavi20 May '09 - 21:25 
GeneralThank youmemberJinousa7 Mar '09 - 3:38 
Generalabout Hijri Calendermemberibless26 Aug '08 - 5:09 
Generaltanks a lotmembersaeiddb3 Aug '08 - 17:55 
GeneralThanksmembershahrzad khorrami12 May '08 - 0:43 
QuestionBUG!!!????!!!!memberbarbod_blue26 Nov '07 - 23:33 
QuestionLeap year calculation algorithmmemberSasanj4 Nov '07 - 2:45 

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 28 Nov 2007
Article Copyright 2007 by Amin Habibi S.
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid