Posted by aangel on October 19, 2012 at 8:50pm
3 followers
Jump to:
| Project: | Date |
| Version: | 7.x-2.6 |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Using the following code:
$date_format = 'Y-m-d h:i A';
$today = date($date_format);
if (isset($blogentity->live_on_date)) {
$the_date = date($date_format, $blogentity->live_on_date);
}
else {
$the_date = $today;
}
$form['live_on_date'] = array(
'#type' => 'date_popup',
'#title' => t('Date this blog goes live'),
'#default_value' => $the_date,
'#date_format' => $date_format, // Uses the PHP date() format - http://php.net/manual/en/function.date.php
'#date_increment' => 5,
'#date_year_range' => '-3:+3', // Limits the year range to the next two upcoming years
'#required' => FALSE,
'#weight' => 130,does not work for me. Neither the date nor time display in their popup fields. Same thing for:
$date_format = 'Y-m-d h:iA';
$date_format = 'Y-m-d h:ia';
$date_format = 'Y-m-d h:i a';
$date_format = 'Y-m-d h:i A';
However, military time works just fine:
$date_format = 'Y-m-d H:i';
Comments
#1
I'm also having this issue. The README.txt in date_popup clearly states that 'a' should work:
Is there a working example of this anywhere?
#2
The date_popup seems to require 'Y-m-d H:i' as the #default_value format, but the #date_format will alter the #default_value
So
<?php'#date_format' => 'Y-m-d h:i A',
'#default_value' => date('Y-m-d H:i', $timestamp)
?>
Will result in
Y-m-d h:i A showing to the end user.