Questions about performing arithmetic operations on dates and times.
Questions tagged [date-math]
129 questions
0
votes
4 answers
Count the number of days from Twitter XML
I'm using the Twitter API to get my recent tweets from an XML file into my website.
I already have the tweets displaying on my page but I can't get it to show how many days have passed since the displaying tweet.
I've already tried some solutions…

CIRCLE
- 4,501
- 5
- 37
- 56
0
votes
4 answers
Convert Unix Timestamp to time from now in PHP
I have a timestamp like this: 1362466800
I want to output it to something like this:
Time left: 1 Year 2 Months 5 Days 17 hours 6 Minutes Left
Also if there is less than 1 year or less than 1 month etc.. That part of the string needs to be…

Talon
- 4,937
- 10
- 43
- 57
0
votes
2 answers
Days between two dates and time
$dday = mktime(13, 00,00, 02, 07, 2013);
$today = mktime(12,30,00, 02, 08, 2018);
$difference = $today - $dday;
$DateCalculation = floor($difference / 84600);
echo $DateCalculation;
The day is 1. But actually its not 1. The day will be…
0
votes
1 answer
PostgreSQL: how to get Day One?
Trying to port a T-SQL CTE to PostgreSQL. In T-SQL cast(0 as datetime) returns
1900-01-01 00:00:00.000
Is there an equivalent 'side-effect' in pg, to get Day One of the epoch?
EDIT:
to_timestamp(0) on my machine --returns 1969-12-31 19:00:00-05.…

Tim
- 8,669
- 31
- 105
- 183
0
votes
1 answer
T-SQL DateMath: for any given date, find occurrence of the dayname in month, e.g. 3rd Saturday
I am trying to develop a scheduling application that needs to represent rules such as "this event occurs on the 2nd and 4th Wednesdays of the month" or "this event happens on odd-numbered Saturdays of the month (i.e. the 1st, 3rd, and 5th…

Tim
- 8,669
- 31
- 105
- 183
0
votes
3 answers
Deprecated: mktime(): The is_dst parameter is deprecated
standard function: ( see on codepad )

bernte
- 1,184
- 2
- 19
- 34
0
votes
2 answers
perl date manipulation
I have a task in perl in which I need to execute 'some_code' but only if date is older than 24 hours counting from now. I'm trying the below code but it doesn't seems to be working.
sub function {
use Date::Manip::Date
use Date::Parse
use…

user1240622
- 59
- 5
0
votes
2 answers
Portable way to add dates between Oracle and MySQL?
Is there any way to add dates/times that will be portable between Oracle and MySQL?
For example, in Oracle, adding col + 1 to a date column will add a day.
In MySQL, adding col + 1 to a datetime column will add a SECOND.
Is there a function that…

wrschneider
- 17,913
- 16
- 96
- 176
-1
votes
2 answers
I Can't seem To Use a tinyint value for System.DayOfWeek in C#
I have my "day of the week" for an event stored as a tinyint in SQL Server table.
0 for Sunday, 1 for Monday, etc.
When I pull back a row from the database, I need to use that tinyint value but as a System.DayOfWeek value (whatever the heck that…

JustJohn
- 1,362
- 2
- 22
- 44
-1
votes
2 answers
Get next 2 days not counting current day in PHP
I have an Unix timestamp like this 1660293621 (2022-08-12 8:40). I want to get next 2 days not counting current date. I expect the result to be 2022-08-15 00:00.
I tried
strtotime("+3 Days", $current_date)
but it returns 2022-08-15 8:40, not…

Stern
- 29
- 6
-1
votes
1 answer
How do I convert my constant into a timezone?
I'm using Python 3.7. I have this defined in my settings file ...
TIME_ZONE = 'America/New York'
I want to make the "now()" function timezone aware, so I can do some date subtraction ...
int(round((datetime.now(settings.TIME_ZONE) -…

Dave
- 15,639
- 133
- 442
- 830
-1
votes
2 answers
Why do different date math operations produce the same value?
I can add six days to a date and get what I expect, but if I add seven days to that same date, I get the same date.
What I mean is this; when the user has enter "12/27/2015" as the value for the @BegDate parameter, this declaration:
DECLARE…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
-1
votes
1 answer
php DateTime acting weird
So i have this code to determine difference between present time and datetime field value from database.
This code gives weird output (samples below) for dates that are not in same year.
$deadline = new DateTime($someDeadline, new…

3ND
- 430
- 1
- 6
- 17
-1
votes
1 answer
Compare dates, monthly period + 1 day
I need to compare current date against a starting date, idea being that on every month + 1 day it will return as if only one month has gone by. So if starting date is 2014-10-27, on 2014-11-27 it will still show Less than a month ago, and on…

fran35
- 145
- 12
-1
votes
1 answer
PHP Why does the DateTime diff function always return zero?
I have the following code that tries to calculate hours worked. I'm having a bit of an issue in that hours and minutes always returns zero. My best guess is it has something to do with the new DateTime, but I have no idea how to remedy…

user3690146
- 106
- 2
- 8