Determine whether timestamp is 50 seconds ago [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How to know if $database_row_datetime is 50 seconds ago?
For example:
if $database_row_datetime is 50 seconds ago {
echo "This post was sent now";
}
Here is my timestamp variable:
var_dump($database_row_datetime) => string(19) "2015-04-28 15:20:09"

<?php
if ((time() - strtotime($database_datetime)) < 60) {
This is a quick, dirty solution for one if statement.
The correct way to handle this is with DateTime and DateInterval classes.

Related

PHP convert integer to time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I convert integer to time in minutes e.g. 5 would give 30mins. I've tried
<?php
$toMin = 5;
echo date('i', ($toMin*60)).'mins';
?>
But it only returns 05mins
so something like:
$time='7.5'; //, 8.3, 2.2.
$x=explode('.',$time);
$min=60*($x[1]/10);
echo $x[0] .'hours and '.$min.'mins';

Calculate remaining days of leave - php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say:
The start day is January 5 and the end is January 10 and the current date is January 7. I want to output the remaining days which is 3.
I think the easiest method is like this.
$date1 = new DateTime("2015-01-01");
$date2 = new DateTime("2010-02-05");
$diff = $date2->diff($date1)->format("%a");

php mysql want to add 30 days from a feild [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i want to add 30 days from the date $first and the result in $sec to take the data between these days from MySQL
$first=05/02/2014
result as in
$sec= 06/02/2014 in m/d/y format
thank you
try
echo $sec=date('m/d/y',strtotime('+30 days', time($first))); //06/04/14

Strange difference between formatted date and original date [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I tried to get events from google calendar. So I have trouble in time output.
$date = DateTime::createFromFormat("Y-m-d\TH:m:sP", "2013-02-12T21:00:00-05:00");
echo $date->format('H:m');
Output is 21:12, but it should be 21:00. How it can be fixed?
m is months. You're looking for minutes which is i:
$date = DateTime::createFromFormat("Y-m-d\TH:i:sP", "2013-02-12T21:00:00-05:00");
echo $date->format('H:i');

time conversion zendframework integer to time php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have time in a format of an integer example:(454 seconds) and i need to convert it to a time format example:(00:07:34) any function can help me to do this??
You can do it using Zend_Date:
$time = new Zend_Date();
$time->setTime('00:00:00');
$time->addSecond(454);
echo $time->toString('HH:mm:ss'); // result 00:07:34

Categories