Jump to content

Quick Date Format Question?


Solarpitch

Recommended Posts

If you mean, convert a time-stamp into an actual readable date then you're looking for date(), if you mean change the date into a time-stamp then I think you want mktime().

 

<?php
// Example...
$timestamp = "12859325";
$time= date( 'l  jS M Y, g:i a', $timestamp );
echo( $time );
?>

Right, I see what you mean. I am starting to wonder if there are issues with the date function in php 4? I have the below function that will take a start time and a finish time and bascially loop through start to finish producing 15min intervals in between.

 

When I test this on php5 it works fine, however on php4 it wont populate the combo box with the generated loop list. Thats why I am afraid to try using the way you specified

 


<?php 

function get_lunch_time($lunch_start, $lunch_finish){


$st = strtotime(date('Y-m-d') . $lunch_start);
$en = strtotime(date('Y-m-d') . $lunch_finish);
$int = 15 * 60; // number of seconds in 15 minutes


$select = "<select name=\"time\" id='listboxes' >";
	for ($i = $st; $i <= $en; $i += $int) {
    $time = date('h:i a',$i) . "<br>\n";
	$select .= "<option value=\"".$time."\">".$time."</option>";
}

$select .= "</select>";

return $select;
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.