Answers for "easiest way to show current date in react"

1

easiest way to show current date in react

import React from "react";

// Rearrange date value to get the order you want... also replace / with a cooler separator like ⋅
export default function App() {
  const current = new Date();
  const date = `${current.getDate()}/${current.getMonth()+1}/${current.getFullYear()}`;

  return (
    <div className="App">
      <h1>Current date is {date}</h1>
    </div>
  );
}
Posted by: Guest on December-27-2021
1

how to get current date in react js

export function getCurrentDate(separator=''){

let newDate = new Date()
let date = newDate.getDate();
let month = newDate.getMonth() + 1;
let year = newDate.getFullYear();

return `${year}${separator}${month<10?`0${month}`:`${month}`}${separator}${date}`
}
Posted by: Guest on March-10-2021

Code answers related to "easiest way to show current date in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language