admin管理员组文章数量:1406063
I am working on a system where I am asked to set an exact time point with this format dd/MM/yyyy HH:mm:ss, the problem is that I can't find a way to add a datetimepicker that contains all that at once, The ponent MUI's DateTimePicker is very ugly, and I like the native datepicker (it's the one I'd like to use) but I've only been able to choose the full date, hours, minutes but not seconds. Is there a way to do it? So far my code is like this (I also attach an image of the result):
<TextField
id="datetime-local"
label="Next appointment"
type="datetime-local"
defaultValue={ new Date() }
InputLabelProps={{shrink: true,}}
/>
This is what I have so far
I am working on a system where I am asked to set an exact time point with this format dd/MM/yyyy HH:mm:ss, the problem is that I can't find a way to add a datetimepicker that contains all that at once, The ponent MUI's DateTimePicker is very ugly, and I like the native datepicker (it's the one I'd like to use) but I've only been able to choose the full date, hours, minutes but not seconds. Is there a way to do it? So far my code is like this (I also attach an image of the result):
<TextField
id="datetime-local"
label="Next appointment"
type="datetime-local"
defaultValue={ new Date() }
InputLabelProps={{shrink: true,}}
/>
This is what I have so far
Share Improve this question asked Jan 15, 2022 at 7:22 Luis SandovalLuis Sandoval 111 silver badge2 bronze badges2 Answers
Reset to default 3material-ui has pickers: @material-ui/pickers
You can use it with format
option:
import React, { useState } from 'react';
import { DateTimePicker } from '@material-ui/pickers';
function App() {
const [selectedDate, handleDateChange] = useState(new Date());
return (
<DateTimePicker format="dd-MM-yyyy HH:mm:ss" value={selectedDate} onChange={handleDateChange} />
);
}
export default App;
You can incorporate these views within your DesktopDateTimePicker ponent as follows:
<DesktopDateTimePicker
views={['year','month','day','hours', 'minutes', 'seconds']} />
This configuration allows users to select years, months, days, hours, minutes, and seconds within the DesktopDateTimePicker ponent.
本文标签: javascriptDateTimePicker with datehoursminutes and secondsStack Overflow
版权声明:本文标题:javascript - DateTimePicker with date, hours, minutes and seconds - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744959077a2634541.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论