score:0
You can use a prop called dateFormat
to format the date to your desired output. To get the days as Sun Mon Tue
, pass dateFormat="ddd"
as a props to the component. Like this way
<DatePicker
dateFormat="ddd"
onChange={this.handleChange} />
score:0
The DayPicker allows you to pass custom elements for the days of the week using the weekdayElement
prop. Thus, you could create a Weekday
element, translate the name to the long name using the formatWeekdayLong
method from react-day-picker utils, and cut that name down to a string of 3 characters. Something like the following worked for me:
const Weekday = ({ weekday, className, localeUtils, locale }) => {
const longWeekday = localeUtils.formatWeekdayLong(weekday, locale);
const newWeekday = longWeekday.substring(0,3);
return <div className={className}>{newWeekday}</div>;
};
// Date Picker Component
const InputDatePicker = () => {
return (
<div className='input-date-picker__container'>
<DayPicker
weekdayElement={<Weekday />}
/>
</div>
);
};
If you look at the localeUtils
parameter passed to the Weekday
component you will see there are a lot of handy methods passed there.
score:1
Use:
dateFormat={"EEEE"}
Or:
dateFormat={"EEE"}
score:4
You can use useWeekdaysShort attribute of react-datepicker.
e.g:
<DatePicker>
useWeekdaysShort={true}
</DatePicker>
score:21
Source: stackoverflow.com
Related Query
- How can I change the format for react datepicker days of the week?
- How can I change the icon in material-ui date picker for React
- How can I change the font size for a <h1> in react bootstrap col?
- How can I change the URL for a React app that I'm hosting myself and to which I forward a domain?
- How can I change css for the React code depending on the Redux state (true or false)
- How can I test a change handler for a file-type input in React using Jest/Enzyme?
- How can I change the color of a Link in React with Material-UI?
- How can I define the type for a <video> reference in React using Typescript?
- How can I reuse the API data for all the pages in react js
- How can I programmatically set the user details for Launch Darkly in my react app
- React : How to stop re-rendering component or making an API calls on router change for the same route
- Ant Design Calendar: How to Change the Day of Week Format
- How i can create the function for the countdown in React native?
- How can I format my values for the x-axis in nivo line?
- How can I change the default port in react from 3000 to another port?
- How to change the height of MUI Datepicker input box in React
- How can I Post the correct week days using react-day-picker
- How do I get my HTML form date input to only allow specific days of the week to be chosen using JavaScript, React and HTML?
- How can I change the underline color of MaterialUI's React Tabs component?
- How Can I refactor my App.js page routes in React ? What is the best practice for that?
- How can I dynamically change the baseURL of my RTK Query api only for a specific group of injected endpoints?
- How can i change the error message in Firebase? For example, when invalid password is entered?
- I am trying to animate an object with css in react and change the animation (timing) dynamically, how can I set the style after animation end?
- How can I change the state of subcomponents with React Router?
- React - How can I access a particular position in the array, and then change it?
- React Test Question: Write a react component that create a list of seven days of week and we can delete any random day of the week on click on it?
- Guys, who knows how you can implement the link format for phone calls in React?
- How to use path in react Router Route for the following format
- How do I change format vAxis for specific targetAxisIndex series in React Google Chart
- How can I pass a value from the backend to a React frontend and use that value in the CSS for the frontend?
More Query from same tag
- Handling Multiple Checkboxes ReactJS?
- interface not matching data
- React how to get index in search
- Best way to reload a ReactJS component to read from localStorage
- Update state object's property with Redux
- Onepage with Gatsby JS and Contentful, how to import my first simple string
- How can I get separated states from multiple child components in React.js?
- Imgur api responding with code 403 with server error 429
- reactjs onclick inside map
- debounce textarea input with react/redux
- How to insert a string into an array the same amount of times as the int value from an input?
- Use a generic types value for a property expecting 'number | string | undefined'
- Nested React routes with dynamic route tags
- Toggle class on menu items with ReactJS
- to extend an object returned from an async function
- Redux-Form overwrite the previous value in React
- Cant apply column on row with flexbox
- How can I make AutocompleteInput or SelectArrayInput scrollable?
- retrieve input values from creativebulma/bulma-tagsinput in React
- Accessing fetch() data that lives in a function
- Material-table ReactJs toggle detailPanel open/closing from actions
- Conditional classes in a reusable react component
- React passing value from dropdown back to parent component
- The conditions don't work in the React render
- How can I get cookies from Express API to React?
- React.render in TypeScript for component with both props and state
- React Context API, updating context
- Change document.body, modify React state and change body again
- Hooking into component
- Deeply updating React state (array) without Immutable, any disadvantages?