Skip to content
Advertisement

Tag: time

How to I get a range of times from a start time and end times with an hour difference using PHP?

$course_hour = 1; $starttime = ’07:00′; $endtime = ’16:00′; I wish if it could return an array of values like below: If $return_array = array(’07:00 – 08:00′, ’08:00 – 09:00′, ’09:00 – 10:00′, ’10:00 – 11:00′, ’11:00 – 12:00′, ’12:00 – 13:00′, ’13:00 – 14:00′, ’14:00 – 15:00′, ’15:00 – 16:00′); If $return_array = array(’07:00 – 08:30′, ‘8:30 – 10:00’,

I need to check if time now is between two times

I need to check IF time is between two times with PHP I tried a lot of examples but they are not working for me, I guess I’m asking a stupid question but I’m not finding any answer. I need to check IF current time is between $datetime1 and $datetime2. IF is between { do something } ELSE { do

PHP negative time calculation

If I add 1 hour and 35 minutes in PHP and subtract 4 hours, I get a remaining time of -3 hours and 30 minutes. But correct would be -2 hours and 30 minutes. Where’s the mistake? Answer $minutes – floor($minutes/60) is positive. So what you’re getting is -3 hours plus 30 minutes, which is -2:30. You need to treat

Show a date depending on day and time

I have this script that echo’s the upcoming Thursday, unless it’s Wednesday because then it shows the Thursday a week later. This works great. But what I would like is to add a cut-off time on Wednesday on 5PM (17:00 GMT+1 / CEST). So before 5PM it will still show the next Thursday (day after) but after 5PM it should

PHP dynamical value as time() function speed in bigdata

What is the preferred (less memory consuming and fastest) approach to use time() or any similar dynamic value in billion+ iterations? A) B) C) I would personally prefer C) but I don’t know how will PHP use memory, if every iteration is storing time as variable? Is it the same in A) and B)? Answer A is surely the fastest,

Add minutes to time based on current time

I am trying to figure out a way to change a value based on current time, currently I am using the following code to add certain minutes the time the order is placed. which is working fine (except for $minutes_to_add = 170 is only adding only 30 minutes to the current time for some reason but I am living with

Why would SQL update the date into tabel to 0000-00-00 00:00:00?

I am trying to update the field SEEN in a SQL table to the current time and date. Here is the code: It sets my SEEN field to 0000-00-00 00:00:00. If I write a specific date directly into the query, say “2021-03-10 02:30:00” it would write that date into the SEEN field. But instead of $now, it would output 0s.

Advertisement