<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.14.0/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.14.0/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
const { useState, useEffect } = React;
const [currentDate, setCurrentDate] = useState("");
// Get the current date and time
const currentDate = new Date();
// Format the current date and time in the desired short format
const formattedDate = `${currentDate.getDate()}/${
currentDate.getMonth() + 1
}/${currentDate.getFullYear()} ${formatAMPM(currentDate)}`;
// Update the state with the formatted date
setCurrentDate(formattedDate);
// Function to format the time in 12-hour format with AM/PM
const formatAMPM = (date) => {
let hours = date.getHours();
let minutes = date.getMinutes();
const ampm = hours >= 12 ? "PM" : "AM";
// Convert hours from 24-hour format to 12-hour format
// Ensure minutes are always displayed with two digits
minutes = minutes < 10 ? `0${minutes}` : minutes;
return `${hours}:${minutes} ${ampm}`;
<div className='container'>
<h3>React Js Current Date Time - 18/07/2023 10:30 AM format</h3>
ReactDOM.render(<App />, document.getElementById("app"));
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12),
0 2px 4px 0 rgba(0, 0, 0, 0.24);