Jump to content

Recommended Posts

Hello.

 

I am trying to create time in the future.

<?php

$time_in_minutes = (round($time / 60));
$future_time = date("H:i:s",time() + 60 * $time_in_minutes);

?>

 

It all works. I get something like "15:58:28". Now if i want to insert this record into the database, which type should i pick? DATETIME or TIMESTAMP?

 

Note that i want to check whether the current time has now passed the future time.

 

Thanks:)

Edited by Pain
Link to comment
https://forums.phpfreaks.com/topic/274108-php-time-in-the-future/
Share on other sites

Why not just the DateTime class with a relative time format?

$time = new DateTime ('+1 hour');

This has the added benefit of dealing with not only midnight automatically, but also leap seconds.

 

In any case, I'd go for a TIME field for this. Since you're only storing the time.

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.