Rank 3: Container
Hello. I am having issue with the dates in appwrite. For some reason, the date are printing out one day before the current day.
Here is code:
const today = new Date();const formattedToday = today.toDateString().slice(4); // Format the date as "MM-DD-YYYY"
console.log(formattedToday);
const todayPosts = entries.documents .filter((post) => { const postDate = new Date(post.LaunchDate); console.log(postDate); console.log('____________________'); const formattedPostDate = postDate.toDateString().slice(4); // Format the date as "MM-DD-YYYY" console.log('Formatted: ' +formattedPostDate); return formattedPostDate === formattedToday; // Filter posts with matching formatted date }) .sort((a, b) => b.Upvotes.length - a.Upvotes.length);
const posts = entries.documents.sort( // sort the posts based on the number of upvotes (a, b) => b.Upvotes.length - a.Upvotes.length);