Jump to content

Random times? [SOLVED]


reed0427

Recommended Posts

Right now, all flights have a set departure and arrival time. Scheduled times. Charter flights are not scheduled and so their departure time can be more random. A charter to XYZ may leave at 0700 this time, but next time it may leave at 1900. For my charter flights it would be nice if the departure time was randomly assigned somehow.

Link to comment
Share on other sites

Been working on this and finally got a result although I don't know how to implement this into the schedules if that's what you want:

<?php
$min_time = 6;
$max_time = 21;
$random_hour = rand($min_time,$max_time);
$number_formatted = str_pad($random_hour, 4, "0", STR_PAD_BOTH);
if ($random_hour < 10){
echo $number_formatted;
}
else
{
echo number_format($random_hour,2,"","");
}
?>

$min_time is the earliest the flight can leave and max is the latest. Hope this helps ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...