Home Programming Facebook platform Date-picker FBML component

Date-picker FBML component

E-mail Print
Share/Save/Bookmark
I've already wrote about my disappointment that date picker is not a part of FBML. There I also added some JS (FBJS) code that one can use to add a date picker. But this code (especially if you need more than one date to pick) becomes very hard to read and to manage. So I wrote a PHP class that manages and outputs date-picker for us.

PHP date-picker for FBML features

  • improved FBJS code
  • automatic client-side date verification (user cannot input 31. Februar)
  • you can choose between date and date-time picker
  • after submiting get dates in MySQL format like YYYY-MM-DD hh:mm:ss
  • gettext translations

Structure

_lib/
    calendar.js.php
    calendar.php
    calendar.tmpl.php
img/
    cal.gif
sl_SI/
    LC_MESSAGES/
        main.po

Usage

You have to include and create object only once! When object is created you call functions setDateTimeField() and setDateField().

Example

require_once('_lib/calendar.php');
$onlyOneObject = new fbCalendarInput();

//date and time input fields
$x->setDateTimeField("firstOne");

//we dont care for time, only date input
$x->setDateField("secondOne");

$x->setDateTimeField("third");

Download

Download in compressed ZIP file

Thanks

The JS is based on code provided here.

Thanks to Johnson for giving us a starting point and to all those who have posted their findings and work-arounds to the various FBJS pitfalls. Big thanks to S10sys for producing and sharing their code for a working fbjs date picker.
Hits: 2305
Comments (6)Add Comment
February 03, 2010     
Fix the bugs
You are little away from the target please fix the code
Atif | 58.181.108.91
February 12, 2010     
usage example
hi,
please put here an example of how to use this...
thanks.
sharon | 95.35.117.244
February 14, 2010     
Get the current date
Hi,
thank you for the calendar! I have some questions :
1) How I can make the calendar to set the current date when it loads?
2) how I can make the month values to start from 0 and end to 11 (0-11), so the Jan to be with value="0" and Dec to be with value="11"?
Ivaylo Cherkezov | 77.78.142.15
February 15, 2010     
responses
@Atif: what do you mean?
@sharon: example for PHP is already written. Read the article.
@ivaylo: you can use FBJS for 1 and 2. In second question you can simply extract 1 from given number.

For more detail help, please donate. Thanks!
Miha. | 89.212.41.47
February 16, 2010     
Setting date
Is it possible to set the date like this?

$today = date("Y-m-d");
$cal->setDateField("mydate" , $today);

Carl | 62.56.86.250
February 16, 2010     
use JS for date setting
This code was written a while ago. As far as I remember it should pick the current date by default.
Object input is for fields name, not date.

Miha. | 89.212.41.47

Write comment

busy
Last Updated ( Wednesday, 04 November 2009 11:37 )  

Sponsored Links

My friends

Bookingpoint
partner websites

Donate

Do you find content useful? Please donate so I can cover my hosting expenses! Thanks!