Dates, Dynamic Dates and Date Picker

I am only just starting to get round to using date and time data and I am confused so I need some help and guidance. I have done the usual trawling through the various posts here, videos, and looking on DMXZone.

Background information
PHP, MySQL, loads of dates in existing database tables set as DATETIME and exist in the following ways
2018-10-17 21:09:30
0000-00-00 00:00:00
NULL

When I use the Bootstrap 4 Form Generator the date fields are created as type="date" but no date shows when viewed in the browser, just the dd/mm/yyyy. All the other fields show correct data.

image

If I then manually add a Date Picker in place of the date field and copy over the id and name and play with the formatting then I can get the date to show correctly.

image

What am i doing wrong and what am I doing right?


Then moving on, how can I dynamically populate these fields?

image

Static Value (A) wants to be today’s date, so something like {{NOW}}. This would obviously show if there was no data coming from a database and could be changed by the user.
Min Date (B) wants to be, say, 12 months ago ie {{NOW -12 months}}
Max Date © wants to be, say, 6 weeks in the future ie {{NOW +6 weeks}}
Is this possible?

Or should I add this detail by way of php

If the later then I could set up a variables at the top of the page or global variables or cookies to then insert in each Date Picker

I am looking for the most efficient way to work with many dates and times.

In form generator use type TEXT and not date. Then on the page add the datepicker to the text field and it will work fine.

As for setting dynamic min/max dates - do this using the dynamic attributes and use the results of a database query, or any other dynamic expression ... no php code.
Select the datepicker and add new dynamic attribute:

@Teodor Haha brilliant! Long question - short answer. That I like. Cheers Teodor I will have a play.

2 Likes

OK, looking good so far. How can I put TODAY as an expression?
Obviously not like this as it doesn’t work :smile:

image

Add date and time component in app structure, set its interval to days.
Use its value as an expression there.

:grin: Happy days!
That works great.
I did see the Date and Time component but wasn’t sure what it was or how it worked so steered clear.
Is this little snippet documented anywhere? Here or DMXZone?

I will try to add it into our docs in the next few days :slight_smile:
What it does it - it provides the current date and you can set a refresh interval :slight_smile: - useful for countdowns etc.

1 Like

I suppose I might have investigated it further if the component had said “Current Date and Time” or something similar. And it’s not so obvious that Interval means “Refresh Interval”, or at least not to me :slightly_smiling_face: I like things spelt out in plain and simple language. Treat me as if I know nothing :crazy_face:

So that’s what it does !! I was wondering … lol.

1 Like

Wow @Teodor, how time flies :laughing: has it really been days since you said you would add it to the docs? Great work with the quick tut.

1 Like

Hope it makes working with current dates a bit more clear now :slight_smile:

3 Likes

Hi, I am trying set a data range from start and end dates from the db?

Tried to use Invalid Dates or Costume dates linked to the server connect action but is not working as expected.

Any tutorials on the subject please. Thank you in advance.

Look in Dynamic Attributes for the Input > Value and use the data picker to choose the relevant date fields from your query. If the dates are stored in the DB they are likely to be yyyy-MM-dd format but just make sure that is the case.

Have you considered using a date-range picker if looking for a range?

Hi, I am already using that field to collect the date from the db from previous input and to be able to edit it.

The workflow I am looking for is:
Main clean event -> valid start time “now” any end time in the future
Sub event -> Valid only between dates of the “main event”

in which case, use the dynamic attributes (under date picker) for min date and max date

1 Like