Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Date format in ListPage field

 

 


avrom
User

Mar 11, 2008, 8:44 PM

Post #1 of 18 (4940 views)
Shortcut
Date format in ListPage field Can't Post

Hi Dave,

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


Dave
Staff / Moderator


Mar 12, 2008, 10:28 AM

Post #2 of 18 (4934 views)
Shortcut
Re: [virgodesign] Date format in ListPage field [In reply to] Can't Post

No problem. :)

The list viewers use the standard PHP date function to format the date. So you're code probably looks like this:


Code
<?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.

Dave Edis - Senior Developer
interactivetools.com
 


avrom
User

Mar 12, 2008, 11:36 AM

Post #3 of 18 (4932 views)
Shortcut
Re: [Dave] Date format in ListPage field [In reply to] Can't Post

Ah yes,

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


Dave
Staff / Moderator


Mar 12, 2008, 5:43 PM

Post #4 of 18 (4926 views)
Shortcut
Re: [virgodesign] Date format in ListPage field [In reply to] Can't Post

Oh ok. It doesn't do that, but we can make it do that.

Open /lib/menus/default/list.php and search for this line:


Code
<?php foreach ($listFields as $field): ?>


Replace that with this:


Code
<?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.

Dave Edis - Senior Developer
interactivetools.com
 


avrom
User

Mar 12, 2008, 8:20 PM

Post #5 of 18 (4924 views)
Shortcut
Re: [Dave] Date format in ListPage field [In reply to] Can't Post

Worked Perfectly. Thank you !


avrom
User

Dec 18, 2008, 7:55 PM

Post #6 of 18 (4644 views)
Shortcut
Re: [Dave] Date format in ListPage field [In reply to] Can't Post

Hi David,

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


Dave
Staff / Moderator


Dec 18, 2008, 8:01 PM

Post #7 of 18 (4643 views)
Shortcut
Re: [virgodesign] Date format in ListPage field [In reply to] Can't Post

Avrom,

It should be in the code already. Can you confirm that "Specify Time" is unchecked for your date field?

Let me know.

Dave Edis - Senior Developer
interactivetools.com
 


avrom
User

Dec 19, 2008, 9:37 AM

Post #8 of 18 (4635 views)
Shortcut
Re: [Dave] Date format in ListPage field [In reply to] Can't Post

Hi Dave !! :))

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


Dave
Staff / Moderator


Dec 22, 2008, 12:23 PM

Post #9 of 18 (4607 views)
Shortcut
Re: [virgodesign] Date format in ListPage field [In reply to] Can't Post

Hi Avrom,

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


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:


Code
      if(@$schema[$fieldname]['type'] == 'date') { 
$value = date("Y-m-d", strtotime($record[$fieldname]));
}


Hope that helps! Let me know if that works for you. :)

Dave Edis - Senior Developer
interactivetools.com
 


avrom
User

Dec 22, 2008, 2:14 PM

Post #10 of 18 (4604 views)
Shortcut
Re: [Dave] Date format in ListPage field [In reply to] Can't Post

Worked perfectly, Thanx Dave :))


esteban
User

May 11, 2010, 2:34 PM

Post #11 of 18 (3747 views)
Shortcut
Re: [virgodesign] Date format in ListPage field [In reply to] Can't Post

Help!
What about time in date in 2010 year :-)
I show date like this: <?php echo $artykulyRecord['createdDate'] ?> and don't need time only date: 11.05.2010

Thanks for help


Jason
Staff / Moderator


May 12, 2010, 10:19 AM

Post #12 of 18 (3736 views)
Shortcut
Re: [esteban] Date format in ListPage field [In reply to] Can't Post

Hi,

You could try something like this:


Code
<?php echo date("m.d.Y",$artykulyRecord['createdDate']); ?>


You can take a look at this page:
http://php.net/manual/en/function.date.php
to see what other formatting options PHP has available.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


esteban
User

May 12, 2010, 11:46 AM

Post #13 of 18 (3734 views)
Shortcut
Re: [Jason] Date format in ListPage field [In reply to] Can't Post

Thanks but not working. I have error:

Notice: A non well formed numeric value encountered in /home/trener_osobisty/trener_osobisty/article.php on line 192 01.01.1970

I put this:
<?php echo date("d.m.Y",$artykulyRecord['createdDate']); ?>

and on the end put a date but not corect. Any idea?


Jason
Staff / Moderator


May 12, 2010, 11:54 AM

Post #14 of 18 (3732 views)
Shortcut
Re: [esteban] Date format in ListPage field [In reply to] Can't Post

Hi,

Try changing it to this:


Code
<?php echo date("d.m.Y",strtotime($artykulyRecord['createdDate'])); ?>


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


esteban
User

May 12, 2010, 12:42 PM

Post #15 of 18 (3731 views)
Shortcut
Re: [Jason] Date format in ListPage field [In reply to] Can't Post

Yes! Thank you ! :-)


markr
User

Nov 16, 2011, 9:09 PM

Post #16 of 18 (1086 views)
Shortcut
Re: [Jason] Date format in ListPage field [In reply to] Can't Post

If I use a date/time field as one of my ListPage Fields, what I really want is the ability to to change the date display format as needed for that menu's ListPage. Possible?


Jason
Staff / Moderator


Nov 17, 2011, 9:31 AM

Post #17 of 18 (1068 views)
Shortcut
Re: [markr] Date format in ListPage field [In reply to] Can't Post

Hi,

The best way to do this would be to create a custom plugin to change the format of the date in the list view. That way you can control which sections have the change applied to them and your changes won't be overwritten when you upgrade your version of CMS Builder.

If you have experience creating plugins, you can use the listRow_displayValue filter to modify those values. If you need any help with this, please email consulting@interactivetools.com and we can go over some options.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


InHouse
User

Nov 18, 2011, 9:54 AM

Post #18 of 18 (1063 views)
Shortcut
Re: [markr] Date format in ListPage field [In reply to] Can't Post


In Reply To
If I use a date/time field as one of my ListPage Fields, what I really want is the ability to to change the date display format as needed for that menu's ListPage. Possible?


+1 for this request. It's an onging topic of discussion in the 'future suggestions and product direction' thread.