 form elements usage example of date elements within forms  enable the date api module you might want to add a dependency in the info file of your module date api uses hookelements  to create custom form types you can check the file dateapielementsinc for the list of form types available and for other configuration options adding a date form element is then easy php your form builder function mymoduleform formstate form array snip add many fields to your form creating the date time element starts here provide a default date in the format yyyymmdd hh mm ss date 20081231 000000 provide a format using regular php format parts see documentation on phpnet if you re using a dateselect the format will control the order of the date parts in the selector rearrange them any way you like parts left out of the format will not be displayed to the user format ymd h i form date2 array type dateselect types datetext and datetimezone are also supported see inc file title select a date defaultvalue date dateformat format datelabelposition within see other available attributes and what they do in dateapielementsinc datetimezone america chicago optional if your date has a timezone other than the site timezone dateincrement 15 optional used by the dateselect and datepopup elements to increment minutes and seconds dateyearrange 3 3 optional used to set the year range back 3 years and forward 3 years is the default snip more fields including the submit button return form these are selfvalidating elements you shouldn t need to do anything except include them in your form you pass them parameters for the timezone format and a default value in the format yyyymmdd hh mm ss and it will convert your input into the format the element wants split the date and time into different fields as needed then accept and validate the user input and convert it back into a string in the same format you originally provided yyyymmdd hh mm ss so you pass it a string and it will pass back a string by the time you get to your own validation function you are responsible for doing your own timezone conversion the element uses the timezone just so it can create a date object with the right timezone for doing its formatting so if you need to do timezone conversion you pull your utc date out of the database and convert it to a local date pass that value to the date element then take what it returns and convert it back to utc and store it in the database again if the date popup module is enabled a datepopup element can be used it works like the other elements but splits the date and time into separate parts you control whether it uses date or date and time by the format you supply in dateformat if you don t have any time parts in the format you won t get a time element note that the jquery widget the date part of the popup can only accept a limited number of formats things like ymd or m d y or dmy  