I want to get formatted date text
See original GitHub issueExpected behavior
I want to get formatted date text. I do not know the method.
Actual behavior
Steps to reproduce
handleChange(date, e) {
●===============「I want to get formatted date text.」
}
render() {
return (
<DatePicker
selected={this.state.startDate}
onChange={this.handleChange}
dateFormat="yyyy/MM/dd"
/>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11
Top Results From Across the Web
Convert dates stored as text to dates - Microsoft Support
Convert text dates by using the DATEVALUE function · Enter =DATEVALUE( · Click the cell that contains the text-formatted date that you want...
Read more >Convert date to text in Excel - TEXT function and no-formula ...
To do this, press Ctrl+1 to open the Format Cells dialog and select Text on the Number tab.
Read more >Convert Date to Text in Excel - Explained with Examples
Select the cells that have dates that you want to convert and copy it. Convert Date to Text - copy paste 4 ·...
Read more >6 Ways to Fix Dates Formatted as Text in Excel
6 ways to fix dates formatted ast text in Excel, plus a bonus technique using Power Query to fix various formats.
Read more >How to Transform Date Text to Date Formatted Text ... - YouTube
Find amount of days that have passed between two dates - Open Office Calculator https://youtu. be /jKQvkxDu2ew 18. Conditional formatting : How ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You should import “date-fns/format” as it is the library used by the react-datepicker. So first import:
import format from "date-fns/format";
then
<DatePicker selected={this.state.startDate} onChange={(date)=>this.handleChange(format(date, "yyyy/MM/dd", { awareOfUnicodeTokens: true }))} dateFormat="yyyy/MM/dd" />
and
handleChange(date) {...
@BladeOnardo I get an error: Starting with v2.0.0-beta.1 date-fns doesn’t accept strings as arguments. Please use
parseISO
to parse strings.When using parseISO on the date, I get:
TypeError: Object(…) is not a function
This library comes with a dependency on date-fns, and as @Himakuma pointed out, makes no sense if we can’t use the functions (and documentation that shows how to use it) when it simple doesn’t work.