How to find the first day of previous month in unix mmddyyyy format?
example : today is 07052007 (in mmddyyyy)
output sud be 06012007
thanks
mohapatra (10 Replies)
Hi,
I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
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 have one question regarding the date. I wanted to display the month name for previous day. The output should be as follows...
5-Feb-09 => February
1-Feb-09 => January
28-Feb-09=> February
Here is the code i am using to get the output....
date '+%m %d %Y' |
{
read MONTH DAY... (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 find the previous month last day minus one day, using shell script. Can you guys help me to do this.
My Requirment is as below:
Input for me will be 2000909(YYYYMM)
I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Hi Guys,
How to get First day of previous month and last day of previous month from trunc(sysdate) using SQL..?
Thanks in advance.
Br,
pinpe (2 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 have requirment to get last date of previous month and the first date of previous 4th month:
Example:
Current date: 20130320 (yyyymmdd)
Last date of previous month: 20130228 (yyyymmdd)
First date of previous 4th month: 20121101 (yyyymmdd)
In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies
LEARN ABOUT PHP
gmmktime
GMMKTIME(3) 1 GMMKTIME(3)gmmktime - Get Unix timestamp for a GMT dateSYNOPSIS
int gmmktime ([int $hour = gmdate("H")], [int $minute = gmdate("i")], [int $second = gmdate("s")], [int $month = gmdate("n")], [int
$day = gmdate("j")], [int $year = gmdate("Y")], [int $is_dst = -1])
DESCRIPTION
Identical to mktime(3) except the passed parameters represents a GMT date. gmmktime(3) internally uses mktime(3) so only times valid in
derived local time can be used.
Like mktime(3), arguments may be left out in order from right to left, with any omitted arguments being set to the current corresponding
GMT value.
PARAMETERS
o $hour
- The number of the hour relative to the start of the day determined by $month, $day and $year. Negative values reference the hour
before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s).
o $minute
- The number of the minute relative to the start of the $hour. Negative values reference the minute in the previous hour. Values
greater than 59 reference the appropriate minute in the following hour(s).
o $second
- The number of seconds relative to the start of the $minute. Negative values reference the second in the previous minute. Values
greater than 59 reference the appropriate second in the following minute(s).
o $month
- The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the
year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0
is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s).
o $day
- The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) refer-
ence the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous
month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the
relevant month reference the appropriate day in the following month(s).
o $year
- The year
o $is_dst
- Parameters always represent a GMT date so $is_dst doesn't influence the result.
Note
This parameter has been removed in PHP 7.0.0.
RETURN VALUES
Returns a integer Unix timestamp.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 7.0.0 | |
| | |
| | $is_dst parameter has been removed. |
| | |
| 5.1.0 | |
| | |
| | As of PHP 5.1.0, the $is_dst parameter became |
| | deprecated. As a result, the new timezone han- |
| | dling features should be used instead. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
gmmktime(3) basic example
<?php
// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", gmmktime(0, 0, 0, 7, 1, 2000));
?>
SEE ALSO mktime(3), date(3), time(3).
PHP Documentation Group GMMKTIME(3)