PHP - Calendar, Datepicker Calendar

The calendar component written in php script. It contains 2 modes: normal display calendar and date picker. See the demo below to check whether your browser support this script or not.
 
Demo:

Fixed Display Style

Date 1 :
  • Set default date to server date (Auto unset if date is disabled)
  • Set year navigate from 1970 to 2020
  • Allow date selectable from 13 May 2008 to 01 March 2015
  • Not allow to navigate other dates from above
  • Disabled Sat and Sun
  • Show calendar weeks

Code:

<?php
$myCalendar = new tc_calendar("date2");
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d'), date('m'), date('Y'));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1970, 2020);
$myCalendar->dateAllow('2008-05-13', '2015-03-01', false);
$myCalendar->startMonday(true);
$myCalendar->disabledDay("Sat");
$myCalendar->disabledDay("sun");
$myCalendar->writeScript();
?>

DatePicker Style

Date 2 :
Select
  • Default date to current server date (Auto unset if date is disabled)
  • Set year navigate from 1960 to 2015
  • Allow date selectable from 01 January 2010 to 01 March 2015
  • Allow to navigate other dates from above
  • Disable specific date 1, 13, and 25 of every month
  • Custom alert when calendar's value has been changed

Code:

<?php
$myCalendar = new tc_calendar("date1", true);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(01, 03, 1960);
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1960, 2015);
$myCalendar->dateAllow('1960-01-01', '2015-03-01');
$myCalendar->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
$myCalendar->setOnChange("myChanged('test')");
$myCalendar->writeScript();
?> <script language="javascript">
<!--
function myChanged(v){
alert("Hello, value has been changed : "+document.getElementById("date1").value+"["+v+"]");
}
//-->
</script>

DatePicker with no input box

Date 3 :
  • No default date
  • Set year navigate from 2000 to 2015
  • Allow date selectable from 13 May 2008 to 01 March 2015
  • Allow to navigate other dates from above
  • Date input box set to false
  • Set alignment left and bottom
  • Disable specific date 1, 4 April, and 25 December of every years
  • Disable specific date 10, 14 of every months
  • Disable 1 June 2011

Code:

<?php
$myCalendar = new tc_calendar("date5", true, false);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d'), date('m'), date('Y'));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(2000, 2015);
$myCalendar->dateAllow('2008-05-13', '2015-03-01');
$myCalendar->setDateFormat('j F Y');
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year');
$myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month');
$myCalendar->setSpecificDate(array("2011-06-01"), 0, '');
$myCalendar->writeScript();
?>

Date Pair Example

from:

Code:

<?php					
$date3_default = "2013-05-20";
$date4_default = "2013-05-26";

$myCalendar = new tc_calendar("date3", true, false);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date3_default)) , date('m', strtotime($date3_default)) , date('Y', strtotime($date3_default)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1970, 2020);
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->setDatePair('date3', 'date4', $date4_default);
$myCalendar->writeScript();

$myCalendar = new tc_calendar("date4", true, false);
$myCalendar->setIcon("calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date4_default)) , date('m', strtotime($date4_default)) , date('Y', strtotime($date4_default)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(1970, 2020);
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->setDatePair('date3', 'date4', $date3_default);
$myCalendar->writeScript();
?>

Example of submiting value: click here

Download zip file: calendar.zip (41.13 KB.)
Version 3.69 (21 May 2013)

What's new

Version 3.69

  • [Added] Use php DateTime class to handle date and also support for year 2038 and later (limited to php version >= 5.3.0)
  • [Fixed] Check valid of Today date if it is in range of enabled date
  • Minor bug fixed and adjustment

Version 3.68

  • [Fixed] 1st and 31st (on each month) are always disabled when running with php4

Version 3.67

  • [Fixed] Javascript possible error on Date.parse
  • [Fixed] Add on-change javascript in dropdown datepicker mode

Version 3.66

  • [Fixed] json checking function produce error when the php does not support for json

Version 3.65

  • [Fixed] Date selected hilight error
  • [Added] Auto hide calendar and make it default property
  • [Added] Auto focus an overlapping calendar to the top

Version 3.64

  • [Fixed] Incorrect parameter submited on javascript that caused an invalid date returned

Version 3.63

  • [Changed] Make the DatePair function selectable on any dates. Date-from must be before Date-to, and on the other hand, otherwise it will be reset

Version 3.62

  • [Fixed] Error displaying date on Jan 2012 and some other months

Version 3.61

  • [Added] Display weeks
  • [Added] RTL supported
  • [Added] startDate function for selecting any days as start day of week
  • [Adjusted] Rearrange source code on calendar_form.php

Version 3.60

  • [Added] Add X as background of disabled days
  • [Fixed] 'Day' combobox contain no list dropdown when not call setDate() on initialization
  • [Fixed] Fixed display style still have the default value in case of the date is disabled.
  • [Fixed] 'Today' date color disappear when date is disabled.
  • [Fixed] Javascript error from IE compatible not support for JSON
  • [Adjusted] Change the color of today date to green with border

Version 3.59

  • Update to match the version with localization

Version 3.58

  • [Fixed] the value of calendar is not restored when using back button on browser

Version 3.57

  • [Fixed] update calendar.css display glitch

Version 3.56

  • [Fixed] error on checkSpecifyDate, calendar.js

Version 3.55

  • [Fixed] 'dateAllow' contains error on calendar_form.php

Version 3.54

  • [Update] 'setSpecificDate' to set on month, year, and no recursive simultaneuosly
  • [Added] 'setOnChange' to customize onChange event of calendar

Version 3.53

  • [Fixed] writeYear contains unused variable (error), sorry guys :(

Version 3.52

  • [Fixed] datepair error after cleaned up code (on version 3.50)

Version 3.51

  • [Added] check_json_encode and check_json_decode for the server that not support json

Version 3.50

  • [Added] setSpecificDate to enable or disable date specified
  • [Improved] Cleaning up and more validating source codes (thanks to Peter)

Version 3.41

  • [Fixed] calendar header - look tight
  • [Fixed] Using incorrect path on example file (index.php), forgot to add history logs on class file

Version 3.4

  • [Added] setAlignment
  • [Added] setDatePair

Version 3.3

  • [Fixed] Total number of days in datepicker mode on startup incorrectly appear (thanks to Francois du Toit, ciprianmp)

Version 3.2

  • [Fixed] Some confusion in date display when both dateAllow and setYearInterval are set in some cases
  • [Fixed] add 'zindex' property to tc_calendar, helps in overlapping component (ie6)
  • [Improved] Year navigate from newest to oldest

Version 3.1

  • [Added] disabledDay (thanks to Jim R.)
  • [Improved] Day style adjustable with css (.mon, .tue, .wed, .thu, .fri, .sat, .sun)

Version 3.0

  • [Fixed] day combobox not update (February case) when select date from calendar
  • [Fixed] auto resize not applied when calendar start in hide div mode (display: none;)
  • [Fixed] day combo box not update when selecting date < 10 (occured from v2.9)
  • [Fixed] (18 May 2010) glich on IE7 update on calendar_form.php and calendar.css
  • [Fixed] (22 May 2010) parseInt error on calendar.js function isDateAllow()

Version 2.9

  • [Improved] Auto adjust calendar size (width & height)
  • [Fixed] Valid day combo box when selecting month or year (input box mode)


Download tc_calendar with language pack (by Ciprian)

Demo: http://www.ciprianmp.com/scripts/calendar/
Download: http://www.ciprianmp.com/scripts/calendar/calendar_localized.zip

Copyright
This calendar datepicker is totally free to use. You can use it in all of your projects without any costs.
How to setup:

Only 2 steps requires for setup and use this calendar component.

Put the javascript file(.js) in the head section or somewhere else but it should be include once in a page.

<head>
<script language="javascript" src="calendar.js"></script>
</head>

Create form element in the html and put the following code

<form action="somewhere.php" method="post">
<?php
//get class into the page
require_once('classes/tc_calendar.php'); //instantiate class and set properties $myCalendar = new tc_calendar("date1", true);
$myCalendar->setIcon("images/iconCalendar.gif");
$myCalendar->setDate(1, 1, 2000);
//output the calendar
$myCalendar->writeScript();
?> </form>

How to get the value?

To get the date selected in calendar by php after submit the form, simple write script as the following:

<?php
$theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";

?> 

The above script should be on another file that html form point to. The parameter 'date1' is the object name that you set in the code at the time calendar construct. See further in Functions and Constructor below.

To get the date selected by javascript on the current page, write script as the following:

<form action="somewhere.php" method="post" name="form1">
<?php
//get class into the page
require_once('classes/tc_calendar.php'); //instantiate class and set properties $myCalendar = new tc_calendar("date1", true);
$myCalendar->setIcon("images/iconCalendar.gif");
$myCalendar->setDate(1, 1, 2000);
//output the calendar
$myCalendar->writeScript();
?> </form> //use javascript to get the value <script language="javascript"> <!-- function showDateSelected(){ alert("Date selected is "+document.form1.date1.value); } //--> </script> //create link to click and check calendar value <a href="javascript:showDateSelected();">Check calendar value</a>

Calendar Properties

rtl - specify the right-to-left direction of calendar

Ex. $myCalendar->rtl = true;

zindex - specify the zindex value to calendar

Ex. $myCalendar->zindex = 99;

Calendar Functions

Constructor

tc_calendar (string bindObjectName)

tc_calendar (string bindObjectName, boolean date_picker)

tc_calendar (string bindObjectName, boolean date_picker, bool show_input)

date_picker default value is false.
show_input default value is true

Methods

autoSubmit (bool flag, string form_name, string target_url)

Specify the calendar to auto-submit the value. Default value of autosubmit is false

To set calendar auto submit, specify flag to true and you need to specify either form_name or target_url to make the calendar to perform autosubmit correctly

Ex 1. $myCalendar->autoSubmit(true, "myForm");
//assume that the calendar is in the form named 'myForm', then tell the calendar to auto submit the value (other values in myForm will be submitted together by html post method)

Ex 2. $myCalendar->autoSubmit(true, "", "anywhere.php");
//tell the calendar to submit the value to 'anywhere.php'. This method will submit only calendar value via html get method

dateAllow (date from, date to, bool navigate_not_allowed_date)

Specify date range allow to select. Other dates from input will be disabled. The parameter navigate_not_allowed_date will handle the user to navigate over the disable date, default is true (means allow)

Specify both date from and to will set range of date user can select.
Specify only date from or to will set range from/upto year set by setYearInterval method.

Ex 1. $myCalendar->dateAllow('2008-05-13', '2010-03-01', false); //allow user select date from 13 May 2008 to 1 Mar 2010
Ex 2. $myCalendar->dateAllow('2008-05-13', '', false); //allow user select date from 13 May 2008 upto whatever can navigate
Ex 3. $myCalendar->dateAllow('', '2010-03-01', false); //allow user select date from whatever can navigate upto 1 Mar 2010

disabledDay (string day)

Specify day column to be disabled. Possible day value: Mon, Tue, Wed, Thu, Fri, Sat, Sun

Ex. $myCalendar->disabledDay('Sun'); //disable Sunday column

getDate ()

Get the calendar value in date format YYYY-MM-DD

Ex. $myCalendar->getDate(); //return 2009-06-19

setAlignment (string horizontal_align, string vertical_align)

Optional: Set the alignment of calendar datepicker with the calendar container. The value of horizontal alignment can be 'left' or 'right' (default) and the value of vertical alignment can be 'top' or 'bottom' (default).

Ex. $myCalendar->setAlignment('left', 'top');

setAutoHide (bool auto, int delay_time)

Optional: Set an auto hide of calendar when not active. The calendar has default value of auto hidden since version 3.65 with default delay time of 1000 (1 second)

Ex 1. $myCalendar->setAutoHide(true, 3000); //auto hide in 3 seconds
Ex 2. $myCalendar->setAutoHide(false);

setDate (int day, int month, int year)

Optional: Set default selected date to the value input. For month parameter: January=1 and December=12

Ex. $myCalendar->setDate(15, 6, 2005); //Set the date to 15 June 2005

setDateFormat (string format)

Optional: Set the format of date display when no input box. Apply with 'showInput' function

Ex. $myCalendar->setDateFormat('j F Y'); //date will display like '9 September 2009'

setDatePair (string calendar_name1, string calendar_name2, string default_pair_value)

Optional: Set a date pair link to calendar object. This function will work when 2 calendars are setup together.

Ex 1. $myCalendar->setDatePair('date1', 'date2'); //This means when the value of calendar 'date1' is set, the calendar 'date2' will not allow to select the date prior to 'date1'
Ex 2. $myCalendar->setDatePair('date1', 'date2', "2011-03-26"); //suppose you are setting this value on date1 object, '2011-03-26' will be assigned as default date of date2 and calculated

setIcon (string url)

Optional: Set icon in date picker mode. If the icon is not set the date picker will show text as link.

Ex. $myCalendar->setIcon("images/iconCalendar.gif");

setHeight (int height) - deprecated since v2.9 - auto sizing applied

Optional: Set height of calendar. Default value is 205 pixels

Ex. $myCalendar->setHeight(205);

setOnChange (string value)

Optional: Set the onchange javascript function to calendar

Ex. $myCalendar->setOnChange("javascriptFunctionName()");

setPath (string path)

Optional: Set the path to the 'calendar_form.php' if it is not in the same directory as your script. The path string is a relative path to the script file.

Ex. $myCalendar->setPath("folder1/");

setSpecificDate (array dates, int type, string recursive)

Optional: Set the specific to enable or disable.

dates: the array of date, and date should be in format YYYY-MM-DD
type: enable or disable the date specified. 0=disable, 1=enable
recursive: '' (blank)=no recursive, calendar will process only on exact date, 'month'=monthly recursive, or 'year'=yearly recursive

Ex 1. $myCalendar->setSpecificDate(array("2011-04-22"));
Ex 2. $myCalendar->setSpecificDate(array("2011-04-22"), 0, 'month'); //disable date 22 every month
Ex 3. $myCalendar->setSpecificDate(array("2011-04-22"), 0, 'year'); //disable 22 Apr on every year

setText (string text)

Optional: Set text to display. The text will show in date picker mode when the icon is not set.

Ex. $myCalendar->setText("Click Me");

setWidth (int width) - deprecated since v2.9 - auto sizing applied

Optional: Set width of calendar. Default value is 150 pixels

Ex. $myCalendar->setWidth(150);

setYearInterval (int year_start, int year_end)

Optional: Set the year start and year end display on calendar combo box. Default value is +15 and -15 from current year (30 years)

Ex. $myCalendar->setYearInterval(1970, 2020);

showInput (bool flag)

Optional: Set the input box display on/off. If showInput set to false, the date will display in panel as example above 'DatePicker with no input box'. Default value is true

Ex. $myCalendar->showInput(false);

showWeeks (bool flag)

Optional: Display weeks on calendar upon setting. Default value is false.

Ex. $myCalendar->showWeeks(true);

startDate (bool date_number)

Optional: You can choose any day as a start day of week. The possible values are 0 (for Sunday) through 6 (for Saturday). Default value is 0 (Sunday)

Ex. $myCalendar->startDate(6); //start day of week is Sat.

startMonday (bool flag) - deprecated since v3.61 - use startDate instead

Optional: Set whether the calendar will be start on Sunday or Monday. Set flag to true means the calendar will display first date as Monday, otherwise false will display first date as Sunday. Default value is false.

Ex. $myCalendar->startMonday(true);

writeScript()

Write the output calendar to the screen

 

 

Visitor Review  Write a review
Search Review :

annoy on 03 Dec 2012 09:39 reply

why on earth would you put greek as the sample language and making changes does not seem to work i tried en_GB en_US and still shows greek...

ciprianmp on 03 Dec 2012 11:58 reply

I put Greek as a random choise and because it's a very good sample of utf-8 implementation.
Why on the earth would you ask for help if you don't provide a link to see it in action?

Anyway, you shall not use the sample.txt to build your script, it's just a sample. You'd better use the index.php...
 

Brenelyn on 30 Nov 2012 01:36 reply

Hi,
Thanks a lot with this article.
But I have a question.
I am new in php, javascript, etc.
I wanted that the date selected must be put inside a textbox. I really can't see where I should modify it. When I put it in my php code, the dates was just in their label form, I mean there are not inside a textbox. I am using the date pair. Thanks a lot!

Brenelyn on 30 Nov 2012 07:58 reply

please reply .. please!
I also wanted to ask if I can change the value from 26-Nov-2012 to 2012-11-26?

PLEASE! I'm so desperate.. Sorry :(
ciprianmp on 30 Nov 2012 08:15 reply

We try to answer questions that we understand and have solutions for. In our case, I really don't get what you want. The selected date is already in a text box as per the pair date example above, so what's the question?
Or better, provide us with a link where we can see what your problem is...
 

zNataku on 29 Nov 2012 10:04 reply

Hello,
So I got everything working and great work btw. Although I do have a question. I'm a beginner php learner so you'll going to have to direct me to which file and which string.

i have the calendar on a file form.php and i made the result to echo in thankyou.php. i want to know how to change the format from YYYY-mm-dd to Jan. 15, 2012 when I echo the selection.

thank in advance

zNataku on 29 Nov 2012 10:09 reply

btw i've tried to change every y-m-d to F j Y or j F Y
ciprianmp on 29 Nov 2012 13:51 reply

You don't have to modify anything in the class itself, just in your thankyou.php page:
If we name $mydate your original "YYYY-MM-DD" var, then use strftime to reformat it as you wish:

$mydate = strftime("%b. %d, %Y", strtotime($mydate));
echo ($mydate);

zNataku on 30 Nov 2012 09:32 reply

so i got it to work and the string goes like this

$theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";
$theDate = date('F-j-Y', strtotime($theDate));

The new problem is that whenever it echos it says the year 1969 and not the year selected
ciprianmp on 30 Nov 2012 09:47 reply

You said you already get the right date on page thankyou.php, but not in the format you wish.
It seems you don't actually pass the var to that thankyou page. Or, your date form name is not "date5".
Do you have a link? Or send me both files to have them tested.
zNataku on 30 Nov 2012 10:32 reply

you're right... the name was date1 in one of them... everything works perfectly now. Thanks!
ciprianmp on 30 Nov 2012 10:37 reply

I'm glad I could help ;)
 

Les Mizzell on 29 Nov 2012 09:35 reply

Need a little help please!

I need to be allow only specific dates (coming from a query) to be chosen.

I have the dates in a list "$rdates"

If I do: echo $rdates; the list looks correct. The output is:

"2012-11-27","2012-11-03","2012-11-09","2012-12-04" ... and so forth

So in my calendar code, I've got:
$myCalendar->setSpecificDate(array($rdates), 1, '');

This isn't working though - it's showing ALL dates as disallowed.
If I COPY the output of echo $rdates, and enter that into the calendar code like:

$myCalendar->setSpecificDate(array("2012-11-27","2012-11-03","2012-11-09","2012-12-04"), 1, '');

It works..

So, the $rdates value isn't getting in there correctly for some reason. I have a syntax problem, yes?

Suggestions please? Thanks



ciprianmp on 29 Nov 2012 13:41 reply

It works if you make it this way:
$rdates = array("2012-11-27","2012-11-03","2012-11-09","2012-12-04");
$myCalendar->setSpecificDate($rdates, 1, '');

So you have to push the values from your list (query) into an array type var, not into a list.
ciprianmp on 29 Nov 2012 18:09 reply

Just more clarifications....
The way you did it it just adds the entire string of dates as an element of the array.

A simpler way would be to use explode():
Your query builds a string, which you can convert into an array like this:
$rdates = explode(",", $rdates);
then simply:
$myCalendar->setSpecificDate($rdates, 1, '');

I think you also need to eliminate the quotes in the string first. If so, try this line:
$rdates = array_filter(explode(",", str_replace("\"","",$rdates)));

Let us know if it worked as expected.
Les Mizzell on 29 Nov 2012 18:46 reply

What seems to be work now (but I'm sure there's a better way)

while($mydates = mysql_fetch_array($md))
{
$rdates = $rdates.','.$mydates['startdate'];
}
$rdates = explode(",", $rdates);

... and then:
$myCalendar->setSpecificDate($rdates, 1, '');

What gets more fun, and I'm working on this now - there's a second calendar on the same page that will need this, but the list of dates it receives depends on a value coming from a dropdown ... so I'm sorting out the jquery to do this now.

I'm really a Coldfusion guy, so I'm slowly getting this PHP stuff. Thanks so much for the assistance!
 

Dhyanesh R. Vyas on 29 Nov 2012 06:00 reply

Thanks a ton, Great Help

 

Kasili on 28 Nov 2012 06:46 reply

Wat a wonderful app.

A question though: what if i need to get a difference between 2 dates in days, (say startdate and enddate) and the difference is displayed in a read only text box.

Thanks

ciprianmp on 28 Nov 2012 10:01 reply

Do you mean like this:
http://ciprianmp.com/scripts/calendar/dual-calendar.php

If so, download this demo here:
http://ciprianmp.com/scripts/calendar/dual-calendar.zip
Kasili on 28 Nov 2012 22:50 reply

Thanks ciprian,

It's similar to that but what I would like to have is difference in days displayed in textbox once i am done selecting the 'to date' without necessarily clicking on any button.

Regards
ciprianmp on 29 Nov 2012 13:54 reply

Hmmm, that requires handling javascript, better than I do. I was playing around a bit but no success yet. Maybe Tri can help if he's around...
 

gajendra singh on 27 Nov 2012 13:47 reply

excellent work , i want to know that how it can be converted as month picker

 

ciprianmp on 25 Nov 2012 05:35 reply

You must have something like this in your page:
$myCalendar->disabledDay('sun');
Comment out the line/lines that call the function disabledDay()...

PS: there is no error in the class, just miss-usage

 

Prasanna on 25 Nov 2012 05:12 reply

Hi all, This scipt is excellent. But I am having a problem when I select the date to be the current date. Ex. today is 25 and when I select 25 it gives me the msg "This date is not allowed to be selected".

Pls help me so that I can select any given date.
I appreciate sending me the currected whole code. I am new to php.
Thanks.
Prasanna

ciprianmp on 25 Nov 2012 05:36 reply

You must have something like this in your page:
$myCalendar->disabledDay('sun');
Comment out the line/lines that call the function disabledDay()...

PS: there is no error in the class, just miss-usage...
 

Jim on 18 Nov 2012 06:42 reply

Thanks man! This was really helpful in the web app I'm making. cheers! :)

 

j on 13 Nov 2012 10:55 reply

One problem I had was that I had "require('calendar/tc_calendar.php')" after "<script type="text/javascript" src="calendar/calendar.js"></script>" and this was causing problems. It's a simple problem with a simple fix: just include the tc_calendar file first (above the "head" tag).

 

Rahul Suresh Jawade on 10 Nov 2012 04:53 reply

how should I disable calendar control based on click of a radio button?

 

Chuck Foltz on 09 Nov 2012 13:53 reply

I have a similar problem like Rick R. How do you fix stacking calendars vertically in a table so that the icon or text/ date boxes don't appear over the calendar. I have tried setting different for a fix:

Step1: Add thid to the class variables

static $copies = 0;

Step 2: Add this to function tc_calendar()

self::$copies++;

Step 3: Goto function writeScript()
Step 4: Find this inside that function

echo("<span style=\"position: relative; z-index: $this->zindex;\">");

Step 5: Change that line to this

if(self::$copies > 1 && self::$copies < 18) {
echo("<span style=\"position: relative; z-index: " . ($this->zindex - self::$copies) . ";\">");
}
else {
echo("<span style=\"position: relative; z-index: $this->zindex;\">");
}

Step 6: Change the zindex var to

var $zindex = 20;


This will make the first calendar 20 index and backstep them so that if you stack say 20 calendars in a table on top of each other they will display correctly and not all be the same index level. If you need more then 20 just turn the variable in step 6 up higher or what I did was add a function to set the zindex var so that if I knew I had a page that needed more calendars I set the zindex on the first instance. This way you don't have to edit the file.

I tried to keep it as easy to read as possible if anyone knows easier way to code this be my guest. I just wanted to throw easy to read and understand what I did code up for the public.

OP: You may include this in your project and change it around as needed.

Ra on 15 Jan 2013 23:27 reply

It looks like some code had changed and now, this easy fix, can't be applied.

This what I use (multiple entry form), and later with the help of FOR loop INSERT it into db.

<?php
$myCalendar = new tc_calendar("selecteddate_[]", true, false);
$myCalendar->setIcon("includes/calendar/images/iconCalendar.gif");
$myCalendar->setPath("includes/calendar/");
$myCalendar->setYearInterval(2012, 2018);
$myCalendar->dateAllow('20012-01-01', '2018-12-31');
$myCalendar->setDateFormat('j F Y');
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->writeScript(); ?>

For now I had no luck of getting it to work
 

Hilikus on 09 Nov 2012 04:41 reply

How to disable all weekends ? :)

 

Gianpiero on 07 Nov 2012 10:27 reply

How can I convert in a responsive calendar picker?
I've tried with media query but it doesn't adjust properly.
Thanks

 

Rick R. on 05 Nov 2012 11:47 reply

Hello:

I'm having trouble with the mouseout function for the calendar. I have two PHP pages that use the calendar function. One page causes the calendar to become hidden after 1000 milliseconds, as expected.

Another PHP page, with the same code, partially hides part of the calendar for that 1000 milliseconds and then it completely disappears.

If I change the $auto_hide_time variable to 1 in tc_calendar.php, they both cause the calendar to hide virtually immediately.

Any idea where I should look to figure out why one file is causing the calendar to partially hide during that 1000 millisecond interval?

Thanks,

Rick R.

Rick R. on 05 Nov 2012 13:02 reply

Upon further investigation, it appears related to the use of several calendars aligned vertically on the page. Where the tcday, tcmonth, and tcyear elements exist, the calendar display is blocked by those elements for the 1000 millisecond duration. I've tried changing the z-index for those elements without success.
Chuck Foltz on 09 Nov 2012 13:54 reply

my post above may help you fix this problem.
 

png on 01 Nov 2012 04:05 reply

thanks for this simple date picker but i have problem with blank date. i want the user should select date otherwise focus should be on the datepicker

 

Ken on 31 Oct 2012 05:46 reply

Hi!
Thanks for the datepicker. It was precisely what I was looking for. But I think I've found a bug. It won't render properly if to close to a table. Has anyone else had this problem? It is not a consisten error, but it is consistent between Chrome and Firefox. If I put in a couple of linebreaks more and more of the picker shows up. It seems to be a strange interaction somewere because on other pages where I use this it shows up real nice. Even over tables with the same styling as the one not working. Any ideas?

 

Kim on 23 Oct 2012 04:37 reply

I can't get de the Date Value wether on the Page, nor in my Database. I've tried the advised method:
$theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : ""; with $_REQUEST and with $_POST Parameter, then I tried a simple method through my Form:
$theDate = $_POST["date1"]; but nothing seems to work.
I even can't display the date value on my page with the javascript method described here.

:)(

 

Ashitha N P on 23 Oct 2012 01:32 reply

Hi

I want to display the next month just below the current month,how can we do it?


Thanks

 

Goatlike on 20 Oct 2012 07:59 reply

Thanks for the calendar, it's very useful. But I wonder is it possible to set the holidays into another category?

 

Amar T on 19 Oct 2012 09:30 reply

how change date format from yyyy/mm/dd to dd/mm/yyyy when saving in database.

 

Afreen Kazi on 19 Oct 2012 01:38 reply

I have used this, and found that when i select any date it is not displaying the selected date in the input box, but when i check the value using java script it displays the selected date. Please help me out what i am missing in the code.

 

bright_star on 17 Oct 2012 14:01 reply

Hi

I am not able to place the dta epicker inside a div or inside a table. it always coming on the top of the my out of every table and div.... could you please help me out

 

Paul P on 11 Oct 2012 21:48 reply

On my Date Pair the words 'from' and 'to' do not appear. Where do I insert these so they appear on my webpage.

 

SSJ on 08 Oct 2012 01:57 reply

Hello, thank you for the script. Everything works as expected. But I have one question. can somebody help me to make active days on calendar ( from month before ant days in next month, they a grey ). I need them to make clickable and with same action as current month days(post form with selecte date ). thanky ou!

 

Dan on 06 Oct 2012 18:41 reply

This program is awesome!

I'm trying to figure out how to set the date to the value stored in my MySQL database, does anyone know how to do this? I have been trying but can't figure it out.

 

hima on 28 Sep 2012 04:37 reply

how to retrieve value in dd.mm.yyyy format

 

ks on 26 Sep 2012 16:50 reply

I am trying to use setSpecificDate to enable a specific day that would usually be disabled by the disableDay setting, but the disableDay seems to win out in the conflict, is this not how the setSpecificDate to enabled is supposed to work?

 

pedro on 26 Sep 2012 14:10 reply

thanks for this,

but i have a question. how do i initialize the calendar with a value from my database so that on load it doesnt set the date with today but rather with the one from my database?

Dan on 07 Oct 2012 23:41 reply

This is how I ended up doing it.

$sql=mysql_query("SELECT date FROM news WHERE id = '".$_GET['id']."' ");
while ($row=mysql_fetch_array($sql))
{
$saved_date=''.$row['date'].'';
}
$date_array=explode ("-",$saved_date);
$year=$date_array[0];
$month=$date_array[1];
$day=$date_array[2];

$myCalendar->setDate($day, $month, $year);

Hope this helps you and anyone else trying to do this.
 
See all reviews «Previous 1 2 3 4 5 6 7 8 9 10 Next»
Write a review
Rating:
Your Message:
Name:
Email:
(optional)
(Your email that entered here will not show anywhere on website and will use only reference when someone reply your post)
  I want to receive a copy of email on this post (your email is needed)
 
Code:
 

Search this site