Forums

Display date also a questionmark for me

dhuizinga1 16 Oct, 2016
Hi all,

I had a list full of dates with some other date..
Now I like only the data form the current month.
date before this curront month i don't want tot display
but for me is the difficult that i can't php.. so i dont know which code i must to use, And where in CCv5...
for so far i only work with table and not with custom code because that's a stap to far for me jet.
The date note notation is also an issue
i've configured in my form a simply type text input field and there i use the notation dd-mm-yyyy

a wish for me that the date returns in full date formate.. example: "sunday 16 october 2016"

who know's the anwers for me...
dhuizinga1 16 Oct, 2016
Hi calculus00,

you describe how you can handle the date format whitin a date picker..
I don't use in my form no date picker, because i don't understand the working from it.
GreyHead 16 Oct, 2016
Hi dhuizinga1,

The best way to save dates in a database table to in a yyyy-mm-dd format (you can always change the display format). How are yours saved?

Bob
dhuizinga1 16 Oct, 2016
Hi Bon,

i uses a type=text in stead type=date. I don't know if this the right option... But dates are difficut.. We, in the netherlands uses standard the dd-mm-yyyy format. In form mostly uses mm-dd-yyyy and that's works confusing. I never found a good solution in forms to solve this.
dhuizinga1 16 Oct, 2016

Hi dhuizinga1,

The best way to save dates in a database table to in a yyyy-mm-dd format (you can always change the display format). How are yours saved?

Bob





Thnx Bob, meanwhile i changed my date field form type=text to type=date... but how can i change my display format in "d m y" of full date?
GreyHead 16 Oct, 2016
Hi dhuizinga1,

There are two different things you need to manage here.

a. The date itself, and how it is saved in the most useful way. As I said before, this should be in a format that MySQL understands - yyyy-mm-dd

b. The way in which the date is displayed - this could be any PHP supported format e.g. dd-mm-yyyy or the format that shows 'sunday 16 october 2016'

Because dates can be entered in different ways I recommend that you use a ChronoForm datepicker element in the form Designer tab. You can specify in the settings the date format you want - and you can also add settings to prevent future dates being added. Please see this FAQ

With a datepicker you can probably set the date format to yyyy-mm-dd - users will be able to recognise this as the date they selected. Or, you could stay with dd-mm-yyyy and add a Custom Code action in the form On Submit event to change the format to yyyy-mm-dd before the data is saved.

Once you have the data saved in yyyy-mm-dd format then it becomes much easier to select a range of dates for display and to sort data by date if you need that.

Bob
dhuizinga1 16 Oct, 2016
Hoi Bob,

The forms saves now the day in international yyyy-mm-dd..


But I want to display Sun, 16 Oct 2016.
But I don't know what de php code is to this and where to put it in my CCv5 connection. And I like to list all items from the current month and later and not before the current month

Further you refer to date picker.. ... I made a basic form in CFv5 with an data picker in it only to make a table.. but i don't use that further any more..
When I add or edit a record I do that with CCv5 than the date picker doesn't work. And I don't no how I to add an date picker in ccv5 action tab.

I can't find tutotorials, youtube or other documentation about ccv5. The forum is a black box with many issue but none that I understand.. I am a really newbie in PHP and in CCv5
dhuizinga1 17 Oct, 2016
With the topic between Tgoodrich and Max (Admin) I found almost what I need... (TNX GUYS)

I found to use the display date format...
the PHP date manual http://php.net/manual/en/function.date.php helps me to fine tuning it.

But the names of the days and months are in English.. How can I change it to Ducth?

And the another question. how can i only list the current month
dhuizinga1 19 Oct, 2016
Hi all,

I changed the save format to yyyy-mm-dd as you can see two entries above. But i want to display the date in full format. I found it out how this works... See image:



But I want to display the weekday into the Dutch language.... Is there someone who can explains how this works?

thnx
GreyHead 25 Oct, 2016
1 Likes
Hi dhuizinga1,

From the PHP docs here - "To format dates in other languages, you should use the setlocale() and strftime() functions instead of date()."

Bob
dhuizinga1 25 Oct, 2016
Hi Greyhead,

thnx for this article.. it helps a lot.
date and time display works exact as I like.

thnx again..

1ste question is answered..
so I hope there's something who can help me with a the 2nd
GreyHead 26 Oct, 2016
Hi dhuizinga1,

To show only records from the current month you can add an extra selector to the listing Conditions box. This is easy if you have saved the date in a DATE or DATETIME columns. See this StackOverFlow answer for example.

Bob
dhuizinga1 26 Oct, 2016
Hi Bob,

Whoooo... That's to high and technical info for me... beep beep beep 😀
So I tried this..

This is my Conditionbox at this moment:

<?php
setlocale(LC_TIME, "nl_NL");
?>

SELECT * FROM tpqu4_chronoengine_chronoforms_datatable_Wie_heeft_er_bardienst WHERE bardienst.datum = Month(NOW());


Then nothing appens. When I put the SELECT code between <?PHP and ?> code than changes the date back into international format. I save the data in DATETIME format...

Where am i going wrong??
GreyHead 26 Oct, 2016
Hi dhuizinga1,

Please see this FAQ for the way to write conditions.

Bob
dhuizinga1 26 Oct, 2016
Sorry Bob,

I am a newbie.... i don't get it...

I dont understand this code...

When I used the most simply form in this faq than it results in a blanc page... only the table headers appear and now data.
bardienst.datum is my model.field

<?php
return array('bardienst.datum' => '23-10-2016');
?>
GreyHead 26 Oct, 2016
Hi dhuizinga1,

That date is not in the yyyy-mm-dd format. What is the format in your table?

That should return any records with that string in the datum column. If you don't get any results then perhaps there are no records.

Bob
dhuizinga1 26 Oct, 2016
Hi Bob

Thnx to be patient with me :-)
1st... there are records...
the format in my table is the default.. "0000-00-00 00:00:00"

when I changed array in :

<?php
return array('bardienst.datum' => '2016-10-23');
?>

then the data for this day appear... YEAHHHHH....

But... this is a hard coded date...

When I changed it in:

<?php
return array('bardienst.datum' => 'Month(NOW()');
?> then nothing appears in my list..

when I use the yyyy-mm-dd or dd-mm-yyyy formate.. what's the difference for the Month???
I don't get it.. the month is eactly the same position in the middle..

So the big question for me is how can i change my frontlist display the current month?


Dirk
GreyHead 26 Oct, 2016
1 Likes
Hi dhuizinga1,

You have a misplaced quote in return array('bardienst.datum' => 'Month(NOW()'); so it won't work anyhow.

To do do this you will need to use the complex query format from the FAQ something like this
<?php
return array(":YEAR(`datum`) = YEAR(NOW()) && MONTH(`datum`) = MONTH(NOW())");
?>

Bob
dhuizinga1 26 Oct, 2016
Hi bob

How is it possible.. it Works.. how you do that..

it's such complex material but I want to learn more..

where do I start

Thanx a lot...

Greetz
Dirk
This topic is locked and no more replies can be posted.