arqex / react-datetime

A lightweight but complete datetime picker react component.
2k stars 868 forks source link

Add a defaultTime prop #401

Open shawninder opened 7 years ago

shawninder commented 7 years ago

I'm Submitting a ...

[ ] Bug report
[x] Feature request
[ ] Support request

Steps to Reproduce

Add a defaultTime prop to the element

<ReactDateTime
  dateFormat="YYYY-MM-DD"
  timeFormat="HH:mm:ss"
  defaultTime="23:59:59"
/>

Expected Results

When clicking on a day in the calendar, if defaultTime is set, the datetime obtained should show the provided default time (in my example above: "23:59:59") instead of "00:00:00" as it currently does

Actual Results

Nothing, hence the feature request

Why?

I am using this component to make a DateTime range picker and I'd like the default times to be "00:00:00" for the "From" input, but "23:59:59" for the "To" input, yet I need the defaultValue to be undefined since I want to support open-ended ranges. Such a new feature would make this use-case really easy:

<label>FROM:</label>
<ReactDateTime
  dateFormat="YYYY-MM-DD"
  timeFormat="HH:mm:ss"
/>

<label>TO</label>
<ReactDateTime
  dateFormat="YYYY-MM-DD"
  timeFormat="HH:mm:ss"
  defaultTime="23:59:59"
/>
k-zaher commented 7 years ago

+1

shawninder commented 7 years ago

I made a PR for this: https://github.com/YouCanBookMe/react-datetime/pull/404

rsl commented 6 years ago

i'd love to see this implemented. defaultValue doesn't fit my needs either.

andyboen commented 6 years ago

I would love this as well.

omkar-joshi commented 5 years ago

+1

dep-deprecated commented 5 years ago

+100

lchangdev commented 5 years ago

+1

michaeldybal commented 5 years ago

+1 Same case with date range

amjad-r-a commented 5 years ago

+1

vebaspect commented 4 years ago

+1

Jenny4831 commented 4 years ago

+1

sneas commented 4 years ago

initialViewDate property could be used to achieve the desired effect.

CarlosPhilipe commented 3 years ago

+1