Show only days in react date picker - reactjs

I want to custumize my DatePicker and only show days cause i want the user to choose one or multiple day from 1 to 31 with ignoring the month and the year
I am using the date picker from "react-multi-date-picker"
<DatePicker
id={"startDate"}
className="form-control"
multiple
format="DD"
/>;

You could use a dropdown or select instead.

You can add following props as below
<DatePicker
id={'startDate'}
className="form-control"
multiple
format="DD"
buttons={false}
disableYearPicker
disableMonthPicker
/>

The prop button={false} helped, and I hid the month and the year too.
Finally, it's exactly as I wanted:
<DatePicker
id={"startDate"}
value={editedDates}
className="form-control"
multiple
format="DD"
buttons={false}
disableYearPicker
disableMonthPicker
hideMonth
hideYear
hideWeekDays
/>
date picker with only days

Related

Change TextInput type="date" format in react-materialize

I need to change the TextInput type="date" display/input format from mm/dd/yyyy to dd/mm/yyyy, I don't care if it is stored as YYYY-MM-DD, but I care about how it displays the input itself.
<TextInput
label="Date Label"
type="date"
value={myDate}
onChange={e => setMyDate(e.target.value)}
/>
I'm not using the full datepicker, I'm only setting the TextInput to type date.
A TextInput of type date is going to render a input with type date. Inputs of type date show the date in a format based on the locale of the user's browser. This allows dates to be displayed in the format expected by the user and you should not alter this behavior.

How to pick multiple dates in one go with react-datepicker?

I know that there are other packages which help in picking multiple dates. But is there any way I can do this using react-datepicker only?
If you are referring to a date range you can use the following format,
<DatePicker
selected={this.state.startDate}
onChange={this.handleChange}
minDate={moment()}
maxDate={moment().add(5, "days")}
placeholderText="Select a date between today and 5 days in the future"
/>
But if you want to pick multiple non continous dates, you will have to refocus on the Date picker component in the onChange function so that the date picker will reappear and pick a date again.

date formatting is painful across the browsers

In my project I am using angularJS and momentJS for fixing the painful date formating part. I have two scenarios, here we go:
Retrieving the date from db and rendering it in UI:
I am getting the response from service in this formate "2016-01-31T20:30:00.000Z". I am using the above and rendering the date and time separately in the following way in UI
<input ng-model="data.startDate" type="date" name="startDate" disabled>
<input ng-model="data.startDate" type="time" name="startTime" disabled>
Its displaying like the image attached below
Its being displayed as YYYY-MM-DD in firefox and in the chrome as DD-MM-YYYY. I want to use the same object for displaying the date and time maintaining the date formate across all the browsers. How it can be achieved ?
I am using this datepicker. When the user selects the date I want show the date in the same format. In this scenario date and time inputs are taken separately and combined in the background.
So can someone help me in fixing the issue.
Convert all date format into string like .ToString("YYYY-MM-DD")
Format datepicker as dateFormat: "yyyy-mm-dd"

Angular 3 dropDown to select birth day

I want to display 3 dropDowns : day,month, and year.
in order to select a birthDay.
Angular.ui datePicker has no this option.Is there any other way to do it?
You could make use of angular-date-dropdowns library or Combodate library
I would prefer you use angular-date-dropdowns.. Here is an example:
<input rsmdatedropdowns ng-model="dob" />

Angular Bootstrap datepicker day issue

I am using angular bootstrap datepicker. Everythings works fine but when I select any date like 20-march-2015 it showing me 19-march-2015(one day less from selected day).
Here is my code in Plunker
This is a daylight saving issue.
Do you get the same issue with dates in February.
Looking at your example you can see the date is
OutPut: "2015-04-26T23:00:00.000Z"
For today :)
if I select 1st Jan, I get
OutPut: "2015-01-01T00:00:00.000Z"
Change your SPAN to
<span>OutPut: {{formData.dueDate | date : 'dd/MM/yyyy'}}</span>
And your good ( note the | date : 'dd/MM/yyyy' )
Actually you don't need datepicker. Delete datepicker and use type="date".
<input ng-model="formData.dueDate" type="date" id="dueDate" name="dueDate"
class="form-control" ng-click="data.isOpen = true">
Example

Resources