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
1
vote
1 answer

PHP DateInterval. Go back to the beginning of the year

I would like to write a method which I can give a period of time (Like: yearly, monthly...) and it returns me an anterior date according to this period of time given. Here is my code: public function callRuleCeilling($period) { $start =…
Kevin
  • 4,823
  • 6
  • 36
  • 70
1
vote
1 answer

How can I get X dates in a range with a minimum interval of 1 minute?

I want to get some random date and time values based on a given date range. Ex: start date: 2015-04-29 08:00:00 and end date: 2015-04-29 20:00:00. Now I want to get the 15 random date and time values and also it should be in minimum 1 minute's…
user1181940
  • 169
  • 1
  • 1
  • 14
1
vote
1 answer

Add months equal to a field value to another field

I'm trying to write a query to extract the rows "not expired" I have a database with a table in which are there : IdActivity lifespan (months) And another table in which I have: IdSubject IdActivity StartDate Now I want to extract all…
genespos
  • 3,211
  • 6
  • 38
  • 70
1
vote
1 answer

From a List of Intervals, Finding all Sets of Intervals where EACH Interval in One Set Overlaps with All Intervals in that Set

Instead of querying a list of intervals with a start and end date to retrieve all intervals from the list that overlap with only the search start and end date, what is the best approach to: From a list of date intervals, Find all unique sets of…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
1
vote
0 answers

Finding Overlapping Date Intervals in Python when Intervals can Start and End on Seconds or Milliseconds

What is the best approach to query a list of date intervals for overlapping intervals, given granularity to the second (or even millisecond)? From the exhaustive list of other questions regarding overlapping integer intervals, I was pointed to the…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
1
vote
1 answer

PHP DateTime Interval errors

if (empty($krow['BUSSTRT'])){ $busts = $ts->add(new DateInterval('PT6i5s')); $busDate = $busts->format('m/d/Y H:i:s'); echo "busDate:".$busDate."
\n"; }else{ $busts = new DateTime($krow['BUSSTRT']); $busDate =…
dft99
  • 69
  • 8
1
vote
1 answer

Formatting DateInterval with huge seconds value

Recently I ran into a simple DateInterval issue. The class does not re-calculate its properties after I created the DateInterval object with a huge seconds value as follow: $interval = new DateInterval('PT6685071S'); echo $interval->format("%m…
Raptor
  • 53,206
  • 45
  • 230
  • 366
1
vote
0 answers

IF within 10 minutes from certain time

I'm trying to create a Users Online page for my site with just php. I have a table column called lastactive which is updated as a DATE/TIME (example: 2014-12-13 21:04:15) each time they visit a page. Now I want my Users Online page to show all of…
Ben
  • 101
  • 1
  • 11
1
vote
1 answer

Date difference on Atom dates?

I have 2 dates that I would like to get the difference of using the date_diff function. This is the code I am…
Sevren
  • 301
  • 4
  • 10
1
vote
1 answer

PHP: how many intervals in a year?

Suppose we have a time interval like this: $interval = new \DateInterval('P1M'); Is there a way to calculate how many such intervals will occur in a year? I am specifically looking for something like division of the intervals [which does not work…
Tanner
  • 13
  • 2
1
vote
3 answers

php show link after x amount of days since posting made

I want to add a link "renew post" after X amount of days after the user has posted their post on the website which will rearrange the post to the top (based on date that is retrieved from the database of course). the timestamp format on my database…
user3233664
1
vote
1 answer

DatePeriod with DateInterval P1Y not generate last year

I have such a code: private function validatePeriodArrayYear() { $this->time->setTimestamp( self::$data['to'] ); $year1 = $this->time->format('Y'); $this->time->setTimestamp( self::$data['from'] ); $year2 =…
Hekimen
  • 174
  • 1
  • 2
  • 12
1
vote
1 answer

Can't set properties on a cloned dateinterval object in PHP

Why doesn't this work? // works $date = new DateInterval( 'P1Y' ); $date->y = '2'; // crashes $date_clone = clone $date; $date_clone->y = '2'; I get a "The connection was reset" in my browser when attempting to run this.
aprea
  • 109
  • 1
  • 2
  • 12
1
vote
2 answers

Split DateTime interval to single days

I have a PHP script which receives a set of Events from a database with begin/end DateTimes, which represent working times. Begin | End 2013-08-14 10:00:00 | 2013-08-22 09:30:00 2013-08-08 07:00:00 | 2013-08-08 15:00:00 2013-08-09…
Langdi
  • 229
  • 1
  • 10
1
vote
4 answers

Calculate recurring interval from start date

This is what I have: Start Date (yyyy-mm-dd) Interval : n Interval Type : hour, day, week, month, year This is what I need: is the current time/date in the recurring interval Data/Example: Today : 2013-07-16 12:37 Event Data : …
osomanden
  • 599
  • 1
  • 10
  • 26