106 Posts
krkr
11 years ago
4
Topic

Hi

Got on weird problem with Date Field.

Admin view made with format d.m.Y , after save in Content it shows up wrong way with changed year and date (ex. Admin 15.10.2013 -> Content 13.10.2015). 

If I use Y-m-d in Admin then I can on field in Content make Typo with d.m.Y. and it works fine. (But then I have problem getting several flieds in one line -> here)

So the Q was, why I cant use normally d.m.Y in Admin and then in Content with the same format? Or this is a bug?

Brgds


Get a Book for SEBLOD
11 years ago
0
Level 1

Hello krkr

Are you working with a custom template or position overrides?

If so, let me know and I can provide some PHP to manipulate the datetime value in a save way.

106 Posts
krkr
11 years ago
0
Level 1

Hi

I have override in Content only. But problem appears before this already in Admin after save. Only thing in Admin view is Tabs in mainbody, anything else is as usual. Btw, Date field is not dependant somehow on Joomla date settings or server. 

But throw in code anyway :)

Brgds

11 years ago
1
Level 1

The code I use in my position override goes like this:

First take the value from the date field and make it a datetime object

$artDate = new DateTime($cck->getValue('art_created'));

Then echo it in the desired format

<?php echo $artDate->format('d.m.Y'); ?>

Hope this helps

10 years ago
0
Level 2
Thanks Gebeer, that little tid bit of information got me out of a hole.
Get a VIP membership