Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6479

TS, React Native | Converting string to date gives NaN but works on console [duplicate]

$
0
0

Facing a strange issue wherein my react-native (with TypeScript) returns NaN for the following snippet but it works when I run the same snippet on a JS/TS console

const convertDateStringToSlotString = (date: string): string => {  var dateObject = new Date(date);  return `${dateObject.getHours()}:${dateObject.getMinutes()}`;};

Also tried logging dateObject and it returns Date { NaN }

Example string I am passing -> "2020-08-02 11:00:00+00"


Viewing all articles
Browse latest Browse all 6479

Trending Articles