Hi skarck,
Please try to use code and editCode attributes. This is an example:
TEMPLATE CONTENT #0
[date]
type = text
date = true
code = 0
editCode = 1
CODE #0
$value = get_post_meta( $_REQUEST['post'], $title, true);
if ( $value ) $enforced_value = date('d/m/Y', $value);
CODE #1
$value = date('U', mktime(0, 0, 0, substr($value, 3, 2), substr($value, 0, 2), substr($value, 6, 4)));
The value will be saved as timestamp. Thanks.
Thread Starter
skarck
(@skarck)
thanks,
one more reason to love this plugin!
Trying to do this also… but it sticks to the value calculated in CODE#1 which means that next time it recalculates to the start date (1970).
the code I try
TEMPLATE CONTENT #0
[ev_date]
type = text
date = true
startDate = '1970/01/01'
dateFormat = yyyy/mm/dd
code = 0
editCode = 1
CODE #0
$value = get_post_meta( $_REQUEST['post'], $title, true);
if($value) {$enforced_value = date('Y/m/d', $value);}
CODE #0 (also tried)
$value = get_post_meta( $_REQUEST['post'], $title, true);
if ($value) $enforced_value = date('Y/m/d', $value);
CODE #1
$a = explode("/",$value);
$value = date('l, j F Y', mktime(0, 0, 0, $a[1], $a[2], $a[0]));
lasson, would the simplest thing to do to be just remove the startDate variable? Thats what I did?
Congrats Hiroak, on the great plugin, something like this should be in the core, and this function here to create the timestamp is ace, the only thing that would make it perfect is that the Date is now shown as a time stamp on in the admin ( Obviously! ), however it would be great if we could then force this timestamp into date() function in the admin to make it readable?
Would be cool to have a timeStamp: variable so that we can order by the dates accurately in the wp_query but then have human readable dates in the admin also.
Would you have any suggestions on how to add a Time to the timestamp?
if you get a warning using the code-examples – then use this for code #0
$value = get_post_meta( $_REQUEST['post'], $title, true);
if ( $value ) $enforced_value = date('d/m/Y', (int)$value);
It converts $value from string to integer before feeding it to the PHP date function – which means you won’t get a warning.
Actually use this even though you don’t get a warning – you system-conf might change one day, and all of a sudden the warning will be there
@omisson — did you get this working with query_posts(orderby= …