Questions about performing arithmetic operations on dates and times.
Questions tagged [date-math]
129 questions
-1
votes
1 answer
Minus two dates to get the difference in months
Please i wish to minus to dates to get my result in equivalent months.
$date1 = 01/01/2013;
$date2 = 12/12/2013;
$months = $date2 - $date1;
$months would be 12.
Kindly assist.
Thanks

Ifeoluwapo Ojikutu
- 69
- 1
- 1
- 12
-1
votes
1 answer
Difference between 2 time() values
I have 2 time() values, for example:
1379078542
1379078574
How do I work out their diffidence and display the output as years, months, weeks, days, hours, minutes, seconds etc.
The 2 values above have a difference of 32 seconds I think, so in this…

oshirowanen
- 15,297
- 82
- 198
- 350
-2
votes
2 answers
Current year, specific day and specifc month - PHP
I want compare two dates but something is wrong.
My code:
';
echo 'ChangeDay: '.$data_mudanca.'
'; if($hoje…
'; if($hoje…

FBN
- 185
- 1
- 1
- 11
-2
votes
3 answers
PHP - Resetting Stats
I'm using a WordPress plugin that re-sets its stats every 7 days using the following line of code:
$keep_time = 60*60*24*7; // 7 days for now (TODO: admin setting)
Could someone help me to modify the code to re-set the stats every 6 hours or every…

user3919726
- 1
- 2
-2
votes
3 answers
Minutes between two DateTimes in PHP
I am trying to get the number of minutes between two DateTimes in PHP:
$time = new DateTime($dateString);
$now = new DateTime;
$diff = $time->diff($now);
echo $diff->format('%m');
The result is always 0, although the DateTimes are several hours…

Boris
- 8,551
- 25
- 67
- 120
-2
votes
4 answers
Error (?) in Day counting PHP
Why the answer is 7304 instead of 7300 as I am trying to calculate the number of days for…
-3
votes
2 answers
Pandas Dataframe subtracting float value from a column
Is there a way to subtract a constant value from the whole column?
If my dataframe is
I want to subtract 2.5 from column 1 so that it appears as
Also, is it possible to convert Date+Time into minutes?
Thank you!

Sharon
- 43
- 1
- 5
-3
votes
2 answers
Get Time Difference (I already did a research but i just dont know how to fix it)
The timestamp in my database is 2015-03-03 00:25:39 (Take note that the type = timestamp and the correct current timestamp in my end is 2015-03-02 01:31:00. The difference should be around 23 hours. But now the problem is that the answers provided…

Dev
- 1,592
- 2
- 22
- 45
-4
votes
2 answers
What is the cleanest way to strip leading 0s from the day-of-month portion of dates?
I have this code that shows some build info in an About box:
private void frmAbout_Load(object sender, EventArgs e)
{
Version versionInfo =
Assembly.GetExecutingAssembly().GetName().Version;
lblVersion.Text = String.Format("Version…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862