question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I want to get formatted date text

See original GitHub issue

Expected 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

2reactions
BladeOnardocommented, Jun 13, 2019

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) {...

1reaction
AcidRaZorcommented, Jul 12, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found