| 34 | | // element definitions for this example |
|---|
| 35 | | $elementsDefinition = array( |
|---|
| 36 | | 'xmess' => array( |
|---|
| 37 | | 'type' => 'Date', |
|---|
| 38 | | 'attributes' => array( |
|---|
| 39 | | 'required' => 'yes', |
|---|
| 40 | | 'display' => 'yes', |
|---|
| 41 | | 'edit' => 'yes', |
|---|
| 42 | | 'label' => 'X-Mess eve', |
|---|
| 43 | | 'title' => 'X-Mess', |
|---|
| 44 | | 'description' => 'Tell me when you celebrate x-mess.', |
|---|
| 45 | | 'dateformat' => 'd.F.Y H:i:s', |
|---|
| 46 | | 'presets' => 'no', // use select boxes? yes|no |
|---|
| 47 | | 'default' => time(), // timestamp or strtotime-compatible string |
|---|
| 48 | | 'min' => '-1 month', // timestamp or strtotime-compatible string |
|---|
| 49 | | 'max' => '+1 month', // timestamp or strtotime-compatible string |
|---|
| 50 | | //'returnformat' => 'timestamp' |
|---|
| 51 | | ), |
|---|
| 52 | | ), |
|---|
| 53 | | ); |
|---|
| 54 | | |
|---|
| 82 | | |
|---|
| | 53 | $elementsDefinition = array( |
|---|
| | 54 | 'xmess' => array( |
|---|
| | 55 | 'type' => 'Date', |
|---|
| | 56 | 'attributes' => array( |
|---|
| | 57 | //'required' => 'yes', |
|---|
| | 58 | 'display' => 'yes', |
|---|
| | 59 | 'edit' => 'yes', |
|---|
| | 60 | 'label' => 'X-Mess eve', |
|---|
| | 61 | 'title' => 'X-Mess', |
|---|
| | 62 | 'description' => 'Tell me when you celebrate x-mess.', |
|---|
| | 63 | 'dateformat' => 'Y.m.d. H:i:s', |
|---|
| | 64 | 'presets' => 'no', // use select boxes? yes|no |
|---|
| | 65 | 'default' => time(), // timestamp, ISO 8601 date or strtotime-compatible string |
|---|
| | 66 | 'min' => '-1 year', // timestamp, ISO 8601 date or strtotime-compatible string |
|---|
| | 67 | 'max' => '+10 years', // timestamp, ISO 8601 date or strtotime-compatible string |
|---|
| | 68 | //'returnformat' => 'timestamp' // 'timestamp' or 'isodate' default: 'isodate' => ISO 8601 date |
|---|
| | 69 | ), |
|---|
| | 70 | ), |
|---|
| | 71 | ); |
|---|
| | 75 | |
|---|
| | 76 | // get the element to have some additonal fun with it |
|---|
| | 77 | $el =& $form->getElementByName( 'xmess' ); |
|---|
| | 78 | |
|---|
| | 79 | // If you want to retrieve the date in the date format you specified, |
|---|
| | 80 | // you can use the following method: |
|---|
| | 81 | //echo 'Formatted date: '.$el->getFormattedDate().'<p/>'; |
|---|
| | 82 | |
|---|
| | 83 | // When using the set methods for the default, max and min dates, |
|---|
| | 84 | // you can also use a PEAR::Date object as parameter. |
|---|
| | 85 | //$el->setMax( new Date( strtotime( '+10 years' ) ) ); |
|---|
| | 86 | |
|---|
| | 87 | // If you can't remember what the ISO date format is, simply use the |
|---|
| | 88 | // provided method, getISOFormat() to get a format string for use with |
|---|
| | 89 | // PHP's date() function. |
|---|
| | 90 | //echo 'ISO date: '.date( $el->getISOFormat(), time() ); |
|---|
| | 91 | |
|---|