Content Type with datetime field include seconds

I’m using Strapi to power an API and have a content type with a datetime field named PostedAt.

I’m having trouble figuring out how to get this field to let the user input hours, minutes, AND seconds.
image

I found one page that mentioned updating this file extensions/content-manager/admin/src/utils/dateFormat.js

So I changed datetime to this format datetime: ‘dddd, MMMM Do YYYY HH:mm:ss’ in it, but unfortunately this had no affect after a rebuild. The API returns a full datetime, including seconds so this should be possible I would think.

Looking at the UI for the content type the time input box is type=text and step=30, and it will let me type in minutes that aren’t a 30, i.e. 14:07 for 2pm ET, but won’t let me enter 14:07:44.

Thanks in advance!

Update: Still having trouble getting it to work with seconds, but tracked it down some more.

The input box is coming from buffetjs, which does support seconds after looking into the TimePicker/index.js file. It’s a bool that gets passed into the props.

So as a test, before I went much further, I located this file node_modules/strapi-plugin-content-manager/admin/src/components/FilterPickerOption/Input.js which seems to be what loads the buffet component. Tried hardcoding seconds=true into the component call and rebuilding, and still nothing. Went a step further and put this file into my extensions… folder and rebuilt again, still didn’t affect anything. I’m kind of stumped.

Original post on github discussions: https://github.com/strapi/strapi/discussions/8302

1 Like

Let me bring in @soupette and @HichamELBSI to see if they can provide a bit more assistance.

Currently the Inputs does not use the dateFormat file (if you could open an issue so we can make an update it would be awesome!). Anyway, you can change this line by adding the following props:
displayFormat="DD MMMM YYYY". In order to have the date displayed in French for instance you have to import the corresponding locale at the top of the same file: import 'moment/locale/fr'.

I hope it helps, good luck.

That didn’t really solve anything for the time picker supporting seconds.

It did lead me to the file @buffetjs/custom/src/components/DateTime/index.js and see that seconds is hardcoded to false

@mybrokengnome maybe you could submit a PR to the repository so it the seconds can be enabled using a props?