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

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 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>