Questions tagged [dateinterval]

Data type used for capturing a interval between two date objects. This is found in PHP, Swift, and likely other languages too.

Data type used for capturing a interval between two date objects. This is found in many languages including PHP and Swift (and likely other languages, too).

For more information, see:

221 questions
0
votes
1 answer

Generate a date schedule that executes only on weekdays

I have a date schedule function in PHP which aims to execute only on working days. The code I have at the moment is generating the schedule for all days of the week so the while statement doesn't seem to working and I'm not sure why. I'm a student,…
Ryan
  • 1
  • 1
0
votes
2 answers

Add 1 hour to current DateTime in PHP - Call to a member function add() on a non-object

I've tried multiple examples/questions around and so far I cannot get this to work. i am trying to take the current DateTime, add 1 hour, then set the minutes to 30. Here is what I have: Current Time: $date = date('Y-m-d h:i:s'); //this works and…
jpgerb
  • 1,043
  • 1
  • 9
  • 36
0
votes
3 answers

Finding count of records in given interval

I have a table with user logins, and I want to find the user who logged in to the site more than 3 times in a 5 day period. For example my table is: id | user_id | login_date ---+---------+-------------- 1 | 10 | 10.1.2014 00:00 2 | 10 …
Can
  • 659
  • 1
  • 7
  • 24
0
votes
1 answer

How calculate the difference of hours between two dates in PHP?

This may sound very unlikely to the other question. I have two hour range. $start = 18:00; $end = 2:00; the result 8 hours. sample two. $start = 17:30; $end = 2:00; result 7.5 Hours. How can I get this on PHP code.
freddy
  • 155
  • 9
0
votes
2 answers

How to return a series of dates between two columns with just one statement using Postgres?

I have the following table: create_table "activities", force: :cascade do |t| ... t.date "start_date", null: false t.time "start_time", …
0
votes
5 answers

How to calculate the number of days (difference) between two dates in PHP?

I've one mysql table in that I store two dates say 2015-03-13 and 2015-03-20 and I displays these dates on form with no. of days between these two dates. In this I want PHP code for calculating days.
Vg.
  • 133
  • 2
  • 3
  • 17
0
votes
1 answer

PHP - Get a time interval of an interval

I have been trying to use the DateTime class to calculate an interval. I use the unix timestamp from $_SERVER['REQUEST_TIME'] and a time retrieved from the database to get an interval, which is of time DateInterval. That part works. That interval…
Buttle Butkus
  • 9,206
  • 13
  • 79
  • 120
0
votes
1 answer

How to specify max param in Struts2's Date Field Validator?

This is my validation field of date type and current is an hidden variable having get & setter in action class: 01/01/1920 ${new java.util.Date(current} Your Birth date must be less…
0
votes
1 answer

PHP - DateTime->add not working. Says DateInterval format is wrong

I've been struggling for a few hours on an error that I'm sure it's silly, but I can't find to solve it. My idea is to create a DateTime of (00:00:00), in order to add to it in a loop 4:30 hours per $i. $saldo_funcionario = new…
user3596108
  • 19
  • 1
  • 5
0
votes
2 answers

DateTime Symfony2 hydrating/persisting

So i have this weird problem i don't really understand. I'm just trying to hydrate an object with two datetimes, "beginning time" and "ending time". I get the ending time by adding a DateInterval (3 days in this example ) here is my controller …
oligan
  • 634
  • 6
  • 18
0
votes
1 answer

Week interval query starting on mondays

FIDDLE I need to do a JasperReport. what I need to display is the total number of accounts processes, broken down into weekly intervals with the number of activated and declined accounts. For the weekly interval query I got thus far: SELECT * FROM…
morne
  • 4,035
  • 9
  • 50
  • 96
0
votes
0 answers

PHP DateInterval not return days in hours

I trying calculate the difference of days but I need the return of this function in hours. Well, in my tests follow the code:
Marcos Bergamo
  • 1,073
  • 2
  • 11
  • 19
0
votes
2 answers

Using DateTime to create an interval of time and divide it into days

I am posting a start date and time, and an end date and time , for example: $_POST['start_date'] //this might be 27:04:2013 $_POST['start_time'] //this might be 16:30 $_POST['end_date'] //this might be 29:04:2013 $_POST['end_time'] //this might…
brux
  • 3,197
  • 10
  • 44
  • 78
0
votes
1 answer

Function for parsing a date

I've been trying to create a function that converts something like 3d4h into the current unixtime+the number of seconds within that string. I unfortunately have not been successful, and now I'm turning to you all. Thanks for any help!
benjking1
  • 3
  • 2
0
votes
1 answer

Wrong DateInterval with DateTime diff

I'm comparing two DateTime : //Get the current DateTime $date_now = new DateTime; var_dump($date_now); // 2014-03-10 19:04:29 // I need to subtract 12 hours (I'm using $date_past to fetch $db_date in a request) $date_past = $date_now->sub(new…
cocoggu
  • 401
  • 7
  • 18