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

MYSQL Date before today

This has been asked quite alot but the answer i found dont seem to work, so im posting here to see if someone can help. I have this $sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(order_date) AS order_date, UNIX_TIMESTAMP(order_expected) AS…
snookian
  • 863
  • 6
  • 13
  • 35
0
votes
2 answers

DateTime class how to deal with negative date interval

I have a simple function that returns the number of days between two dates using the DateTime diff function. But right now it still returns a positive number if the end date is before the start date. Is there a way to return a negative difference…
user794846
  • 1,881
  • 5
  • 29
  • 72
0
votes
1 answer

php DateTime diff method behavior

I have to find the days until an expiration date. I tried to use diff method of DateTime class. $dataexp = 2013-11-06 00:00:00 ; $now = 2013-11-05 13:00:00 ; $dtn = new DateTime('now'); $dte = new DateTime($dataexp); $diff =…
Paolo Rossi
  • 2,490
  • 9
  • 43
  • 70
0
votes
2 answers

Symfony date interval with multiple formats

I have a Date interval of an entity called worker with a period of time see the next functions: // Get date of retirement public function getRetireYear() { $this->retireYear = $this->getBirthDay()->add(new \DateInterval('P60Y')); return…
Abel
  • 538
  • 5
  • 8
  • 28
0
votes
1 answer

Convert a "hh:mm"-string to HTML5 microformat duration

I'm trying to convert a string of the format "HH:MM" (for example, 01:25 - 1 hour and 25 minutes), for usage as microdata in a recipe page. I can create a DateTime object from the string like so: $time = date_create_from_format("H:i",…
MadsMadsDk
  • 117
  • 1
  • 3
  • 13
0
votes
1 answer

PHP DateInterval does not applied on DateTime object

I'd like to make an array starts with the first day-o-month and finishes at the last. $days = array(); $sdays = cal_days_in_month(CAL_GREGORIAN, date('m'), date('Y')); $d = new DateTime(); $d->modify('first day of this month'); for($i; $i<$sdays;…
Répás
  • 1,812
  • 7
  • 28
  • 54
0
votes
2 answers

Storing startdate and enddate values from a function to an array

Can someone help me in storing startdate and enddate from a function to an array for further processing. Below php code will give start and end dates of each month for a given period. But I am unable to put these values into an array from the…
sridhar s
  • 149
  • 2
  • 6
  • 12
0
votes
2 answers

MySQL: Cascade filtering by date intervals

Can any help me with such type of query. I have: posts table comments table They are linked through comments.post_id = posts.post_id columns. I user can filter post by comments for the past: 1 hour 24 hours 2 days, etc. If user selected to show…
balkon_smoke
  • 1,136
  • 2
  • 10
  • 25
0
votes
1 answer

php, when number_format() meets date_diff()

my system: win 7 32bit, wampserver 2.1e please help me find out the solution of following confusion.
user995789
  • 279
  • 1
  • 4
  • 15
0
votes
2 answers

How to find the number of DateIntervals between two dates in PHP

I am trying to determine the number of date intervals between two dates. The interval could be a number of months, days, hours or whatever the user has chosen. At the moment I have a function using recursion, however, this will break if there have…
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
0
votes
1 answer

modifying a php DateTime object

I have a question regarding the proper way to modify a php DateTime object. Currently, I'm doing something like: $origEvent = new DateTime(...); $newEvent = new DateTime(...); $someOtherEvent = new DateTime(...); //get the time difference between…
Greg
  • 6,453
  • 9
  • 45
  • 61
-1
votes
1 answer

Swift JSONDecoder type mismatch on parsing ISO8601 DateInterval

I'm trying to parse next sample DateInterval values an Api suplies following ISO 8601 format: [ {"ISO8601":"PT10M","text":"time: 00:10"}, {"ISO8601":"PT1H10M","text":"time: 01:10"}, {"ISO8601":"PT3H20M","text":"time: 03:20"} ] to next…
Matias Masso
  • 1,670
  • 3
  • 18
  • 28
-1
votes
1 answer

Increment Row Index And Union With Other Tables On Dynamic Dates

Question: I looked at various other examples to increment over rows, but all resulted in the same wrong output. The problem which I encountered was that my code did not successfully increment over rows to build a correct index per new row in the…
d_-
  • 1,391
  • 2
  • 19
  • 37
-1
votes
1 answer

DateInterval: year from now

I need to modify the code so it will send 2 years date and not only one year. I have tried to change to $year_from_now->add(new DateInterval('P2Y')); but it will not work. Please see below code: $year_from_now=new DateTime(); …
boulder606
  • 29
  • 1
  • 4
-1
votes
2 answers

PHP how many hours are in certain interval

I have datetimes in the following format: Start: 2017-07-16 20:00 End: 2017-07-16 23:30 Start: 2017-07-18 21:30 End: 2017-07-19 00:30 I need to tell from these intervals how many hours (in 0,5 increments) are spent between 18:00-22:00 and…
ediets
  • 1
  • 1
1 2 3
14
15