Jump to content

PHP Time format


technophobe

Recommended Posts

Hello,

 

I am new to this site so please execuse my ignorance, I have piece of code that returns a time of 00:00:00 however I only want it to return 00:00. ie. 00:11:56 instead of 11:56.

 

Can anyone help

 

Thanks

 

 Time commenced:  
      <select name="time_commenced" id="time_commenced">
        <option value="<?php echo date('Hi'); ?>"><?php echo date('Hi'); ?></option>
        <?php    
$start = strtotime('0700');
$end = strtotime('2000');
?>
        <?php
for ($i = $start; $i <= $end; $i += 360)
{
?>
        <option value="<?php echo date('Hi', $i); ?>"><?php echo date('Hi', $i); ?></option>
        <?php
}
?>
      </select>      
       Time completed:
       <select name="time_completed" id="time_completed">
         <option value="<?php print date("Hi", mktime()+(6*60)); ?>"><?php print date("Hi", mktime()+(6*60));?></option>
         <?php
for ($i = $start; $i <= $end; $i += 360)
{
?>
         <option value="<?php echo date('Hi', $i); ?>"><?php echo date('Hi', $i); ?></option>
         <?php
}

Link to comment
Share on other sites

Use code tags next time you post (the <> button)

 

Read the manual page for date. It has everything you need to know about formatting a timestamp.

 

The code you've posted won't produce the output you're describing however. So you may have other issues.

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.