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 :: Iterate with JavaScript For Loops 
Javascript :: get monitor width javascript 
Javascript :: USA phone number validator angular 
Javascript :: how to remove special characters from a string in javascript using regex 
Javascript :: javascript random int in range 
Javascript :: jest testmatch specific folder 
Javascript :: traverse an array in javascript 
Javascript :: react query dev tools 
Javascript :: UpperCase every first letter in each word in str 
Javascript :: javascript get random items from array 
Javascript :: wait for element to load 
Javascript :: redux saga delay 
Javascript :: join text in js 
Javascript :: factorial of number js 
Javascript :: use import in node 
Javascript :: replace comma by new line in js 
Javascript :: define array with custom index javascript 
Javascript :: show ajax error wordpress 
Javascript :: how you can use javascript to play the sound for the button color selected 
Javascript :: how do i make a link to direct me to a new page when i click on a button in react 
Javascript :: download canvas js 
Javascript :: jquery select clear options 
Javascript :: reverse date javascript from yyyy/mm/dd to dd/mm/yyyy 
Javascript :: javascript remove characters from beginning of string 
Javascript :: extract words from string js 
Javascript :: string split javascript 
Javascript :: kendo clear selection 
Javascript :: queryselector data attribute 
Javascript :: next js absolute path 
Javascript :: lodash remove undefined values from object 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =