import React from 'react';
import {View, Text} from 'react-native';
const Date = () => {
const date = new Date();
const n = date.toDateString();
const time = date.toLocaleTimeString();
console.log('Date: ' + n);
console.log('Time: ' + time);
return (
<View>
<Text>{n}</Text>
<Text>{time}</Text>
</View>
);
};
export default Date;
I'm getting "undefined is not a constructor ,evaluating new Date()" error and " maximum call state exceeded " error I want to display date in the format
Wed, 20 Jan 2022 9:30 PM
How to do this?
You redefined the variable Date as the component has the same name. That way, you cannot access the original Date anymore. Try renaming your component.