Reputation: 29
in my program when I click on a calendar I am getting the "selectedDate" variable changed. Like if I click on 4/6/2021 the value of selectedDate = 04-06-2021, Like if I click on 14/7/2021 the value of selectedDate = 14-07-2021.
I need to get which day of the week the dates are. I am trying in this way:
<View>
<H1 color={color.white}>{days[selectedDate.getDay()]}</H1>
</View>
I need to get which day of the week is the selected date. this syntax is giving an error "Property 'getDay' does not exist on type 'string'"
Upvotes: 1
Views: 4963
Reputation: 749
Use moment https://momentjs.com/
import moment inside your file
moment().format('dddd');
this is the method to get day from a given date
Upvotes: 1
Reputation: 114
you can use moment(https://momentjs.com/) for this. With the help of moment we can get date in different formats. I hope you this will help
Upvotes: 0