Hi, I'm new with Unix, I'm trying to get a last day of previous month with this format: %b %d %Y (example: Feb 25 2008).
Here is what I have so far.
#!/bin/ksh
cur_month=`date +%m`
cur_year=`date +%Y`
prev_month=$(($cur_month-1))
# Check to see if this is January
if
then
... (11 Replies)
Hello,
I wanted to display the month for previous day date. Like, today date is 18-Nov-2008. So the previous date is 17-Nov-2008. The output should be November.
If the today date is 1-DEC-2008, then output should be NOVEMBER.
If the today date is 1-JAN-2008, then output should be DECEMBER.... (4 Replies)
Hello,
I'm new to shell scripting.
We've develop a script which will grep a file on the search criteria, MON (Jan/Feb/Mar/etc). But we should set this sript in cron which will run on every first day of the month. The problem I'm having is, when I run the script, it is displaying the contents of... (7 Replies)
Hi All,
I need to run a job every month at the beginning of the month which is scheduled through autosys, lets say on 03/01/2010. I need to pass the last month's i.e February's first_date = 02/01/2010 and last_date = 02/28/2010 as variables to a stored procedure. Can somebody please pass... (2 Replies)
Hi,
On any given day, I want to capture the month that has gone by - said otherwise, how do I capture last month?
expr date '+%m' - 1
Above expression is giving error.
Please advise
thanks
---------- Post updated at 09:28 AM ---------- Previous update was at 09:11 AM... (1 Reply)
Hi,
i unable to get the last month date in AIX.
current date - one month
Based on the forums tried but did not find the relevent information.
Any help grealy appriciated.
Thanks
Suri. (3 Replies)
Hi All,
I am using the below code to get the year and month from date:
Below gives output like 201212.
dt=`date '+%Y%m'`
how do i get the previous month value(ie: subtract 1 from date)
example output:
dt=201211
Please help. :confused: (3 Replies)
I am running a script in ksh to get the 2 months back date from system date.The below code is giving correct date output from putty command prompt.But while running the script is .ksh file it is giving the error below.Please suggest.
; d=a; y=a
m-=num
while(m < 1) {m+=12; y--}... (1 Reply)
I am not able to fetch first date and last date previous month
date -d -1month +%Y-%m-%d
date -d -1month +%Y-%m-%d
I need two format dd-mm-yyy
previous month 01-03-2016
previous month 31-03-2016
and also only date 1 to 31
Aprriciate your replay (4 Replies)
Discussion started by: jagu
4 Replies
LEARN ABOUT PHP
datetime.modify
DATETIME.MODIFY(3) 1 DATETIME.MODIFY(3)DateTime::modify - Alters the timestamp
Object oriented style
SYNOPSIS
public DateTime DateTime::modify (string $modify)
DESCRIPTION
Procedural style
DateTime date_modify (DateTime $object, string $modify)
Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(3).
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $modify
-A date/time string. Valid formats are explained in Date and Time Formats.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.6 | |
| | |
| | Absolute date/time statements now take effect. |
| | Previously, only relative parts were used. |
| | |
| 5.3.0 | |
| | |
| | Changed the return value on success from NULL to |
| | DateTime. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.modify(3) example
Object oriented style
<?php
$date = new DateTime('2006-12-12');
$date->modify('+1 day');
echo $date->format('Y-m-d');
?>
Procedural style
<?php
$date = date_create('2006-12-12');
date_modify($date, '+1 day');
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2006-12-13
Example #2
Beware when adding or subtracting months
<?php
$date = new DateTime('2000-12-31');
$date->modify('+1 month');
echo $date->format('Y-m-d') . "
";
$date->modify('+1 month');
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-01-31
2001-03-03
SEE ALSO strtotime(3), DateTime.add(3), DateTime.sub(3), DateTime.setDate(3), DateTime.setISODate(3), DateTime.setTime(3), DateTime.setTimes-
tamp(3).
PHP Documentation Group DATETIME.MODIFY(3)