Date format in ListPage field
18 posts by 6 authors in: Forums > CMS Builder
Last Post: November 18, 2011 (RSS)
By avrom - March 11, 2008
Thank you for answering all my questions, I really appreciate your patience and support :)
I have Date as the first field in the ListPage field. It is displaying both the date and time. I would like to remove the time so it only shows the date:
See all the 00:00:00 would like to remove those.
Thanks so much
Date News Item
2008-01-28 00:00:00 Radical Entertainment partners with
Re: [virgodesign] Date format in ListPage field
By Dave - March 12, 2008
The list viewers use the standard PHP date function to format the date. So you're code probably looks like this:
<?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>
So all those letters after date(" represent the date format to be displayed. You can lookup the format codes here: http://www.php.net/date
So you probably want to remove the last few letters there ("g:i:s: a") or whatever you have in your viewer. It will be easy to spot the hour/minute/second format codes because they'll have a colon (":") between then.
Hope that helps, let me know if that does what you need.
interactivetools.com
Re: [Dave] Date format in ListPage field
By avrom - March 12, 2008
But I want to remove the time format actually in CMS Builder for this particular site, so it doesn't show up in the editor fields as 0:00:00. Just want to show the Date.
Cheers :)
Avrom
Re: [virgodesign] Date format in ListPage field
By Dave - March 12, 2008
Open /lib/menus/default/list.php and search for this line:
<?php foreach ($listFields as $field): ?>
Replace that with this:
<?php
foreach ($listFields as $field):
if(@$schema[$field]['type'] == 'date' && @!$schema[$field]['showTime']) {
$record[$field] = date("Y-m-d", strtotime($record[$field]));
}
?>
I'll add that to next version (v1.11) as well.
Let me know if that works how you want it to.
interactivetools.com
Re: [Dave] Date format in ListPage field
By avrom - December 18, 2008
Re this thread: I would like to achieve this in v.1.23 but obviously the code has changes. Can you direct me to the coding I need to change in the newer version (so the date is displayed in the editor without the time).
Thanks so much !!! :))
Avrom
Re: [virgodesign] Date format in ListPage field
By Dave - December 18, 2008
It should be in the code already. Can you confirm that "Specify Time" is unchecked for your date field?
Let me know.
interactivetools.com
Re: [Dave] Date format in ListPage field
By avrom - December 19, 2008
Yes that works fine. Thank you !
Is it possible however that the time could still be entered in the blog area I'm working on, but not displayed in the editor ? Its just too crowded with the time showing as well as the date.
I don't mind removing the time from the editor display globally as the time doesn't need to be displayed elsewhere in the site at all.
Thanking you in advance
Avrom
Re: [virgodesign] Date format in ListPage field
By Dave - December 22, 2008
Sure, here's how to make the change globally.
- Open /lib/menus/default/list_functions.php
- Search for "Y-m-d" and find this code
if(@$schema[$fieldname]['type'] == 'date' && @!$schema[$fieldname]['showTime']) {
$value = date("Y-m-d", strtotime($record[$fieldname]));
}
- Remove the code in red so you're left with this:
if(@$schema[$fieldname]['type'] == 'date') {
$value = date("Y-m-d", strtotime($record[$fieldname]));
}
Hope that helps! Let me know if that works for you. :)
interactivetools.com
Re: [Dave] Date format in ListPage field
By avrom - December 22, 2008