PHP Classes

How to Add Datepicker in PHP Form with PHP date picker class: Generate form input to pick a calendar date

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 8,359 All time: 200 This week: 49Up
Version License PHP version Categories
datepicker 1.0.1Free for non-comm...3HTML, Time and Date
Description 

Author

This PHP class can be used to generate a nice, template driven date picker in a pop-up window.

The class will automatically generate the required HTML and JavaScript code that will make a pop-up window appear to let the user choose a date from a calendar. The selected date will be passed to an user-specified control from the caller page.

Every aspect is customizable: the aspect of the date picker is template driven meaning you can completely alter how the date picker looks by changing the template and the related CSS file; the format in which the date to be returned is configurable; the date picker can be instructed to show a specific year/month/date by default; the first day of the week can be also set;

The date picker also supports localisation: in this version, beside the default english language file you can also choose between german and dutch.

The code is heavily documented so you can easily understand every aspect of it.

Picture of Stefan Gabos
Name: Stefan Gabos <contact>
Classes: 12 packages by
Country: Romania Romania
Age: 45
All time rank: 312 in Romania Romania
Week rank: 132 Down3 in Romania Romania Down
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title>datepicker test</title>
  </head>
  <body>
<?php
   
// requires the class
   
require "../class.datepicker.php";
   
   
// instantiate the object
   
$db=new datepicker();
   
   
// uncomment the next line to have the calendar show up in german
    //$db->language = "dutch";
   
   
$db->firstDayOfWeek = 1;

   
// set the format in which the date to be returned
   
$db->dateFormat = "m d Y";
?>

    <input type="text" id="date">
    <input type="button" value="Click to open the date picker" onclick="<?=$db->show("date")?>">

  </body>
</html>


Screenshots (1)  
  • screenshot.gif
  Files folder image Files (13)  
File Role Description
Files folder imageexamples (1 file)
Files folder imageincludes (3 files)
Files folder imagelanguages (3 files)
Files folder imagetemplates (1 directory)
Plain text file ChangeLog Data changelog file
Plain text file class.datepicker.php Class class source v1.0.1
Plain text file License Lic. license file

  Files folder image Files (13)  /  examples  
File Role Description
  Plain text file example.php Example example script

  Files folder image Files (13)  /  includes  
File Role Description
  Plain text file class.xtemplate.php Class templating engine
  Plain text file datepicker.php Aux. auxiliary script
  Plain text file license.txt Lic. license file of the templating engine

  Files folder image Files (13)  /  languages  
File Role Description
  Plain text file dutch.php Conf. dutch language file
  Plain text file english.php Conf. default language file
  Plain text file german.php Conf. german language file

  Files folder image Files (13)  /  templates  
File Role Description
Files folder imagedefault (2 files)

  Files folder image Files (13)  /  templates  /  default  
File Role Description
  Plain text file style.css Data stylesheet for the template file
  Plain text file template.xtpl Data template file

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Reuses Unique User Downloads Download Rankings  
 0%1
Total:8,359
This week:0
All time:200
This week:49Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:76%StarStarStarStar
Documentation:-
Examples:68%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2464