I have two columns in my database named dtp_s and dtp_e. Both of these columns hold strtotime() formatted ints which I then use in my PHP application to calculate hours/minutes between time intervals. I want to display the 5 most recent records in date order, which works fine when I use this: However, I now want to convert the dtp_s
Tag: datetime
Find records between two time slots in php
i have time slots like $timeslot = [’09:00-10:00′, …. ’23:00-00:00′, ’00:00-01:00′]; I have records with updated time as 23:15:00, 23:30:00, 00:15:00, 09:15:00 etc. What i’m trying to find is the …
How to display days and hours with date() in php
I have a timestamp which calculates remaining time between 2 dates. $job_expiration = strtotime($job[‘job_expiration’]) – time(); like so. Right now, I’m showing only 1 day or 2 days with the date()…
Setting just the year with PHP DateTime
With PHP DateTime you can use methods such as ->modify() ->add() and ->sub() to manipulate the current DateTime object. There are also ->setDate() and ->setTime() methods which allow …
Issue with getting the day of a month with the week day and year
I’m trying to get the day of a month with this code: // your input $month = “September”; $year = “2013”; $dayWeek = “Friday”; $week = 2; // create a date object $date = new …
Check if there is 24 hours gone since a Woocommerce order is made
I call a Woocommerce method $order->get_date_created() that is returning this WC_DateTime object: How can I check if there is more (or less) than 24 hours are gone since the order is made? Answer Here is the way to check if there is more (or less) than 24 hours passed since an order has been created, using WC_DateTime and DateTime methods
DateTime with microseconds
In my code, I’m using DateTime objects to manipulate dates, then convert them to timestamp in order to save them in some JSON files. For some reasons, I want to have the same thing as DateTime (or something close), but with microseconds precision (that I would convert to float when inserting inside the JSON files). My question is : is
How to properly set “0000-00-00 00:00:00” as a DateTime in PHP
I have a column viewedAt which is a DATETIME and accept NULL values. It’s a software restriction to set that column on each new record as 0000-00-00 00:00:00 so I go through the easy way using Symfony and Doctrine as show below: But surprise PHP change that date to this -0001-11-30 00:00:00 and SQL mode in MySQL server is set
PHP Carbon Check If Chosen Date is Greater than Other Date
I’ve started using PHP Carbon for my application since it seems so much easier than using and manipulating date/time with the DateTime class. What I want to do is check if the chosen date ($chosen_date) is greater than another date ($whitelist_date). I have tried this in the code below: The original $chosen_date value comes from POST data. Here is the
Reformatting a datetime field into a more readable format
I am pulling a datetime field out of a database with PHP in the form of this: 2015-09-22T13:00:00 When I populate my html with this value it returns this (note: without the ‘T’): 2015-09-22 13:00:00 No biggie. What I’d like for the output format to look like is this: September 22nd, 2015 – 01:00PM GMT I can’t quite wrap my