18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to generate a random date
How can I generate a random date using javascript. The date should be in DD/MM/YYYY format
Comments
I am using this js functions for date and time
function currentYear()
{
var $today = new Date();
var $dd = $today.getDate();
var $mm = $today.getMonth();
var $yyyy = $today.getFullYear();
$rand = Math.floor(Math.random()*11);
$dd = $rand+$dd;
$mm = $rand+$mm;
$yyyy = $yyyy-$rand;
if($dd>28) { $dd = 28; }
if($mm>12) { $dd = 12; }
if($dd<10){$dd='0'+$dd}
if($mm<10){$mm='0'+$mm}
$randDate=$dd+"/"+$mm+"/"+$yyyy;
{
return $randDate;
}
}
currentYear();
_alert($randDate);
Thank You mohan!!!