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)
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   
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 
NewsUsing this calendar in ASP.NETmemberVahid_Nasiri16-Oct-07 20:24 
GeneralRe: Using this calendar in ASP.NETmemberVahid_Nasiri8-Feb-08 19:05 
GeneralThank You From Iranian Programmermemberhooshang Karami1-Sep-07 19:32 
Questionthank u:-)memberznarges8027-Aug-07 2:28 
GeneralGregorian Calendarmemberminoosh12-May-07 23:50 
GeneralRe: Gregorian CalendarmemberAmin Habibi S.13-May-07 1:16 
GeneralRe: Gregorian Calendarmemberminoosh19-May-07 22:18 
Questionis it possible that the calendar be right to left ?memberkatty_Dev10-Apr-07 2:25 
AnswerRe: is it possible that the calendar be right to left ?memberAmin Habibi S.10-Apr-07 20:57 
GeneralRe: is it possible that the calendar be right to left ?memberVahid_Nasiri16-Oct-07 1:30 
AnswerRe: is it possible that the calendar be right to left ? [modified]memberpoyanfar28-Apr-10 19:38 
Generalproblem in FireFoxmemberAfsoon10-Mar-07 22:24 
GeneralRe: problem in FireFoxmemberAmin Habibi S.10-Mar-07 23:10 
GeneralRe: problem in FireFoxmemberhooshang Karami1-Sep-07 23:32 
Generalproblem with the calendarmemberAfsoon20-Feb-07 23:01 
GeneralRe: problem with the calendarmemberAmin Habibi S.23-Feb-07 21:52 
QuestionNice Code But i have Problem...memberMember #307324718-Feb-07 21:12 
GeneralWell done.memberBahram.M13-Feb-07 0:22 
GeneralRe: Well done.memberAmin Habibi S.13-Feb-07 14:00 
GeneralGreat work!memberSalarSoft10-Feb-07 23:37 
AnswerRe: Great work!memberAmin Habibi S.12-Feb-07 23:20 

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130619.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