Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>
  );
}
Comment

display current date and time in react js

{new Date().toLocaleString() + ""}
Comment

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}`
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: add 24 hours to string date javascript 
Javascript :: bcrypt_lib.node not found 
Javascript :: regex check if number is even 
Javascript :: ng has unexpectedly closed (exit code 127). 
Javascript :: replace multiple spaces with single space javascript 
Javascript :: npm run dev on different port 
Javascript :: javascript end of day 
Javascript :: javascript redirect laravel route 
Javascript :: dynamics 365 javascript set disabled 
Javascript :: window open same tab 
Javascript :: java sleep 1 sec 
Javascript :: javascript difference between two dates 
Javascript :: fetch json post 
Javascript :: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If 
Javascript :: enable/disable textbox on checkbox click using jquery 
Javascript :: rgb to hex javascript 
Javascript :: prevent default window on right click menu 
Javascript :: list of currencies with code js 
Javascript :: Slick slider arrows change 
Javascript :: node log without newline 
Javascript :: javascript get string between two parentheses 
Javascript :: on enter key press react 
Javascript :: angular npm angular material 
Javascript :: how to install robotjs 
Javascript :: how to convert string to kebab case in javascript 
Javascript :: get text of selected option jquery 
Javascript :: how to get year in react 
Javascript :: jquery tag name 
Javascript :: z index style javascript 
Javascript :: js get element distance from top 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =