logo
down
shadow

Adding 2 months in PHP


Adding 2 months in PHP

By : user2956045
Date : November 22 2020, 10:48 AM
I wish this help you You can use DateTime class and modify method argument like last day of second month
code :
$date = new DateTime('2014-12-31');
$date->modify('last day of second month');
echo $date->format('Y-m-d');


Share : facebook icon twitter icon
How to process previous 6 months log to the current months and future upcoming months without manually editing the bash

How to process previous 6 months log to the current months and future upcoming months without manually editing the bash


By : S Kohli
Date : March 29 2020, 07:55 AM
seems to work fine You seem to have the answer already: MONTH=`date -d"6 month ago" +"%Y-%m"` should give you the string 2013-07 (when it's run in January 2014, anyway).
Every place in your script where you literally write 2013-07 and so on, you can just use $MONTH instead. You can make the script more concise to boot by wrapping it in a small loop:
code :
echo "<h2><b>Servers</b></h2>" >> $HTML
echo "<table border="1">" >> $HTML
echo "<tr><th rowspan="2">Month</th><th>CBS</th><th>GFS</th><th colspan="2">HR</th><th>Payroll</th><th>INCV</th></tr>" >> $HTML
echo "<tr><th>cbs1</th><th>gfs1</th><th>hr1</th><th>hr1</th><th>hrm</th><th>incv1</th></tr>" >> $HTML

for count in 6 5 4 3 2 1 0
do
    MONTH=`date -d"$count month ago" +"%Y-%m"`
    CBS=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.22.41 |sort|uniq | wc -l`
    GFS=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.22.31 |sort|uniq | wc -l`
    HR1=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.10.1 |sort|uniq | wc -l`
    HR2=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.21.12 |sort|uniq | wc -l`
    PAYROLL=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.21.18 |sort|uniq | wc -l`
    INCV=`bzcat $LOG/$MONTH*.log.bz2|grep 10.55.22.71 |sort|uniq | wc -l`
    echo " <tr><th><a href=/soc/test/archive/tmp/tripwire.$MONTH.html>$MONTH</a><td>$CBS<td>$GFS<td>$HR1<td>$HR2<td>$PAYROLL<td>$INCV</tr>" >>$HTML
done

echo "</table>" >> $HTML
Mysql query to group by age, 3 months, 6 months, 9 months and 12 months

Mysql query to group by age, 3 months, 6 months, 9 months and 12 months


By : vblearner100
Date : March 29 2020, 07:55 AM
hope this fix your issue , You can put a case statement in the group by:
code :
select (case when date >= date_sub(now(), interval 3 month) then '3month'
             when date >= date_sub(now(), interval 6 month) then '6month'
             when date >= date_sub(now(), interval 9 month) then '9month'
             when date >= date_sub(now(), interval 12 month) then '12month'
        end) as grp, sum(cost) as sumcost
from table t
where date >= date_sub(now(), interval 12 month)
group by grp;
Adding months to current date and if its saturday adding 2 days to input?

Adding months to current date and if its saturday adding 2 days to input?


By : Netheris
Date : March 29 2020, 07:55 AM
Hope this helps Why not just do the calculations on the date object and let the browser handle all the calendar calculations:
code :
// get a date object
// 8 months from 2016-01-01 is a Saturday
var date = new Date(2016, 1, 1);

// add 8 months
date.setMonth(date.getMonth() + 8);

alert(date); // will show a Saturday

// check if it is a saturday
if(date.getDay() == 6)
{
  // if it is then add two days
  date.setDate(date.getDate() + 2);
}

alert(date); // will show a Monday
Grouping months from a date column and adding quantities for all months

Grouping months from a date column and adding quantities for all months


By : Mehadi hassan
Date : March 29 2020, 07:55 AM
it fixes the issue datetime2 is a SQL Server type as far as I know. If so, then you can try the following query:
code :
DECLARE @start_date Date, @end_date DATE
SET @start_date = '2015-01-01'
SET @end_date = '2015-12-31'

SELECT DATEPART(MONTH, entry_date) AS month,
       SUM(order_amt - refund_amt) AS total_revenue
FROM Orders
WHERE entry_date >= @start_date AND entry_date <= @end_date
GROUP BY DATEPART(MONTH, entry_date)
How to generate dynamic expiry dates like 3 months, 6 months, 9 months and 12 months from the today date in php

How to generate dynamic expiry dates like 3 months, 6 months, 9 months and 12 months from the today date in php


By : Antoine Précigout
Date : March 29 2020, 07:55 AM
I wish this help you You could use the DateTime class and the associated methods available such as add and diff
code :
$interval=new DateInterval('P3M');
$now = new DateTime();
$start=new DateTime();
$end=new DateTime( date( DATE_ATOM, strtotime('+1 year') ) );
$end->add( $interval );


while( $start->add( $interval ) <= $end ){
    echo $diff = $start->diff( $now )->format('%a') . '<br>';
}
92
182
274
366
Related Posts Related Posts :
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • What's wrong with my PHP Script? T_String issue
  • how to call a function of another file without including that file
  • is_rgb function in php
  • transform the numbers to letters using php
  • How to catch an exception from another class method PHP
  • PHP exec is blocked by ISP
  • PHP4 to PHP5 migration character encoding. latin1 vs utf8
  • Begin Transaction not defined
  • How much harm can a user do with xss on a page unique to them?
  • How to import data from a php file to javascript variable
  • PHP and Javascript - log complete workflow
  • When I echo !!! 0 it gives me a strange result
  • jquery ajax post dies after submit
  • How to upload file with curl on sftp server
  • Advanced search using a text input to search through only one category
  • Why do I get "Non-static method App\Models\Category::products() should not be called statically" in laravel
  • Stop notices from undefined indexes in arrays
  • PHP Excel Error when entering SUM function to a cell
  • laravel 4 eloquent eager load relation count
  • click submit in html and run php code
  • Extremely frustrating behavior with Internet Explorer, Bootstrap and Respond.js
  • Vkontakte vtag issues
  • Divide the number to a correct decimal
  • mysqli_insert_query not working
  • How to make a sitemap using zend framework 1
  • Laravel: array to Model with relationship tree
  • $_SERVER['DOCUMENT_ROOT'] vs $path = $_SERVER['DOCUMENT_ROOT']
  • What is the best way to store multiple checkbox values in the database and work with it later on
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org