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 );
?>

Link to comment
Share on other sites

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;
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.