Is it possible to prevent the time field to expect seconds in Laravel Backpack? - laravel

I'm working with Laravel Backpack and for a specific model I want the user to be able to add a "start time" using the time field type. I want the user to enter this format: hh:mm.
While creating the entity it works fine. But in the edit mode the value of the input field has this format: hh:mm:ss
The field is declared like this:
[
'name' => 'start_time',
'label' => "Beginn",
'type' => 'time'
],
The corresponding field in the DB looks like this:
$table->time('start_time')->nullable();
When the model is created this works as expected what means, that I can enter the time in hh:mm format. For example I enter "14:00".
After saving the model, in the DB I have the value stored as 14:00:00.
Now, when I go to the edit view the value in the corresponding time input field is also 14:00:00.
I assume this is because in the DB the value is stored including the seconds.
Is it possible to store a time in the DB without the seconds? So just in the format hh:mm?
For more details I have some screenshots that show what I meant:
On creation
enter image description here
enter image description here
The value in DB after saving
enter image description here
The input after loading the edit view
enter image description here

I think you can make it work by defining the step attribute in the field https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time#using_the_step_attribute
Cheers

Related

How to set up a data profile for APEX 21.1 REST Data Source with no row selector available

I'm using APEX 21.1 and have created a REST Data Source for a web service that returns a response in the following format:
[
[
1499040000000, // A time stamp
"0.01634790", // A value
.... etc.
],
[
1499040000100, // A time stamp
"0.01634799", // A value
.... etc.
]
]
The auto-discover function complains about not finding a row selector.
How do I manually set up a data profile for such a type of response?
Thanks,
Ruud
Since this JSON structure is just a nested array, APEX cannot auto-discover that Data Profile. You can get it working as follows:
In the Create REST Source Wizard, use the "Create Module Manually" button
Edit the new REST Data Source
Click the Edit Data Profile button. You should see 3 pre-created columns.
Change the Row Selector to . (a dot)
Edit the first column
Change the column name to TIME_STAMP
Change the selector to [0]
Change the data type to NUMBER
Save the changes
Edit the second column
Change the column name to VALUE
Change the selector to [1]
Change the data type to VARCHAR2
Save the changes
Delete the third column
Save everything.
You should now be able to test the REST Data Source.
Does that help?

How to properly store a DateTime into a database with Timezone in Laravel

My vue Js component is outputting a date in the format below. The component is actually making use of FlatPickr
2017-03-04T01:23:43.000Z
I have done quite abit of research and can see that the ISO time is in the format
2021-05-16T08:09:42+0000
I.e without the trailing 'Z' and also the seperator is a Z '.' and not a '+'
Will I need something like moment to convert the date into a suitable format to store in Laravel?
My column on my database is a DateTime column.
why dont you use carbon to input time directly from the database as you save the rest of the data.
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now(),
``

Quicksight parse date into month

Maybe I missed it but I'm attempting to create a dynamic 'Month' parameter based on a datetime field - but can't seem to get just the month! ? Am I missing something ?
here's my source DTTM date/time field -
In Manage Data > Edit [selected] Data Set > Data source
Just add 'calculated field':
truncDate('MM', date)
where MM returns the month portion of the date.
See manual of truncDate function
The only place in Quicksight that you can get just a month, e.g. "September" is on a date-based axis of a visual. To do so, click the dropdown arrow next to the field name in the fields list, select "Format: (date)" then "More Formatting Options..." then "Custom" and enter MMMM in the Custom format input box.
Quicksight menu selection as described
This will then show the full month name on the date axis in your visual. NB It will use the full month name on this visual for ALL time period "Aggregations" - e.g. if you change the visual to aggregate by Quarter, it will display the full name of the quarter's first month etc.
If you are talking about "Parameters" in the Quicksight analysis view then you can only create a "Datetime" formatted parameter and then only use the "Date picker" box format for this parameter in a control (+ filter).
If you use a calculated field in either data preparation or analysis view the only date functions do not allow full month names as an output, you can get the month number as an integer or one of the allowed date formats here:
https://docs.aws.amazon.com/quicksight/latest/user/data-source-limits.html#supported-date-formats
You'll need to hardcode the desired results using ifelse, min, and extract.
Extract will pull out the month as an integer. Quicksight has a desire to beginning summing integers, so we'll put MIN in place to prevent that.
ifelse(min(extract('MM',Date)) = 1,'January',min(extract('MM',Date)) = 2,'February',min(extract('MM',Date)) = 3,'March',min(extract('MM',Date)) = 4,'April',min(extract('MM',Date)) = 5,'May',min(extract('MM',Date)) = 6,'June',min(extract('MM',Date)) = 7,'July',min(extract('MM',Date)) = 8,'August',min(extract('MM',Date)) = 9,'September',min(extract('MM',Date)) = 10,'October',min(extract('MM',Date)) = 11,'November',min(extract('MM',Date)) = 12,'December','Error')
Also, I apologize if this misses the mark. I'm not able to see the screeshot you posted due to security controls here at the office.
You can use the extract function. Works like this:
event_timestamp Nov 9, 2021
extract('MM', event_timestamp)
11
You can add a calculated field using the extract function:
extract returns a specified portion of a date value. Requesting a time-related portion of a date that doesn't contain time information returns 0.
extract('MM', date_field)

Can't remove hours and minutes from datatable

I'm trying to get release date field with y-m-d format.. Actually time format (for y-m-d) seems fine but also it gives h:m:s too, I changed time format at server side and removed h:m:s but datatable still shows them
What I get
2012-04-11 00:00:00
What I want
2012-04-11
Released_at field (Metronic theme - json datatable)
{
field: "released_at",
title: "Release Date",
type: "date",
format: "YYYY/MM/DD"
}
time format (I'm using laravel framework)
protected $dateFormat = "Y-m-d";
How do I fix this ?
Datatable accept column type same as mysql type.
You are trying to convert mysql dateTime column to Date in datatable, which is not possible from datatable.
In your code you have declared
format: "YYYY/MM/DD" // but actual type is dateTime as per mysql.So it will append time next to it.
If you are storing only date in mysql then you can change column type to Date, and your problem gets solved.
And if you want to convert string to date in laravel you can follow this post.
Your database column is of type dateTime which, by definition, includes both date and time information. If you want to remove the time at a database level then use the date type instead
$table->date("released_at")->nullable();
If instead of removing the time from the database, you just want to ignore it for certain parts of your application, you can leverage the fact than in Laravel all dates coming from your models are Carbon\Carbon instances, so you could do
$model->releasedAt->format('y-m-d'); // Returns '18-09-11'

Form validation rule MS-Access 2007

I have a simple form that gets used to enter information into a table. I want to use a validation rule on the form so that information gets entered correctly. I have a datetime object that must be filled out in a non-traditional form so I just want to check the length and make sure it is equal to 16. I have the following in the form which does not work
=Len([DISCHARGE DATETIME])=16
But when I put the same rule in the table and not in the form it works just fine, any ideas?
Dates should be stored in date data types. In a lot of DBs the date data type is numeric. In MS Access it is a decimal, the integer portion is a date and the decimal a time. It is not difficult to create a query that uses the Format function to modify output to suit an application.
SELECT Format(ThisDate,"yyyy-mm-dd hh:nn:ss") FROM ThisTable

Resources