10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need the date format in YYYY.MM format and I am able to get current month date as well as previous month date with below command
PM=`date +'%Y.%m' -d 'last month'`
CM=`date +'%Y.%m' -d 'now'`
but I need to get YYYY.MM date format for previous 12 months so could you please help me how I get... (2 Replies)
Discussion started by: Amit Joshi
2 Replies
2. Shell Programming and Scripting
Hi Unix Experts,
Happy Morning to all !! :)
I am new to UNIX Shell Scripting and at my begineer level. To get acquainted to scripting, I am trying to create a script.
The details/requirements of my script was to create a script with month changing logic in it so that on every 6th Working... (3 Replies)
Discussion started by: micky3112
3 Replies
3. Shell Programming and Scripting
How to convert date format such as 7/18/2015 to the number of month from requesting date 'date' in sh scripting ?
Let say I have output in my log.txt -> 7/18/2015. How I convert it to the full number of month starting from 'date' till 7/18/2015 in shell scripting ? Thanks in advance. (1 Reply)
Discussion started by: amerabest
1 Replies
4. Shell Programming and Scripting
Hi Guru's,
I am working on a shell script from past a month and unable to get rid of automating while working with dates,here's what i have.
inital_date=11012011
final_date=11302011
expected_output= has to be in below format PFB
11012011
11022011
11032011
*
*
*
11102011
*
*... (9 Replies)
Discussion started by: Gaurav198
9 Replies
5. UNIX for Dummies Questions & Answers
I have files like
pra.01
sra.02
see.03
swc.03
sre.04
after dot it contain month format when ever user type "01" month i have to fetch what are 01 files to come (2 Replies)
Discussion started by: sgoud
2 Replies
6. AIX
Hello,
How do I convert unix timestamp value to 'normal' date format - to get year month and day values ?
Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ?
I don't want to write C program, any ways to do that using unix shells ?
thanks (1 Reply)
Discussion started by: vilius
1 Replies
7. Shell Programming and Scripting
Hi Experts,
How to convert months into numeric format with the help of some script:
Suppose I want:
" Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sept | Oct | Nov | Dec "
to be converted as :
" 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 "
Thanks in... (2 Replies)
Discussion started by: rveri
2 Replies
8. Shell Programming and Scripting
Dear All,
Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report.
to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies
9. Shell Programming and Scripting
i have an variable mydate=2008Nov07
i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month)
i want some command to do this for any month without using any loop.
plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies
10. Shell Programming and Scripting
I need to get the current month -1 in string format, like Feb-2006. I am using k shell.
Any help is appreciated. (3 Replies)
Discussion started by: mogli4
3 Replies
DATEINTERVAL.FORMAT(3) 1 DATEINTERVAL.FORMAT(3)
DateInterval::format - Formats the interval
SYNOPSIS
public string DateInterval::format (string $format)
DESCRIPTION
Formats the interval.
PARAMETERS
o $format
-
The following characters are recognized in the $format parameter string. Each format character must be prefixed by a percent sign (
%).
+------------------+--------------------------------------+---+
|$format character | | |
| | | |
| | Description | |
| | | |
| | Example values | |
| | | |
+------------------+--------------------------------------+---+
| | | |
| % | | |
| | | |
| | Literal % | |
| | | |
| | | |
| | % | |
| | | |
| | | |
| Y | | |
| | | |
| | Years, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03 | |
| | | |
| | | |
| y | | |
| | | |
| | Years, numeric | |
| | | |
| | | |
| | 1, 3 | |
| | | |
| | | |
| M | | |
| | | |
| | Months, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03, 12 | |
| | | |
| | | |
| m | | |
| | | |
| | Months, numeric | |
| | | |
| | | |
| | 1, 3, 12 | |
| | | |
| | | |
| D | | |
| | | |
| | Days, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03, 31 | |
| | | |
| | | |
| d | | |
| | | |
| | Days, numeric | |
| | | |
| | | |
| | 1, 3, 31 | |
| | | |
| | | |
| a | | |
| | | |
| | Total number of days as a result of | |
| | a DateTime::diff or (unknown) other- | |
| | wise | |
| | | |
| | | |
| | 4, 18, 8123 | |
| | | |
| | | |
| H | | |
| | | |
| | Hours, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03, 23 | |
| | | |
| | | |
| h | | |
| | | |
| | Hours, numeric | |
| | | |
| | | |
| | 1, 3, 23 | |
| | | |
| | | |
| I | | |
| | | |
| | Minutes, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03, 59 | |
| | | |
| | | |
| i | | |
| | | |
| | Minutes, numeric | |
| | | |
| | | |
| | 1, 3, 59 | |
| | | |
| | | |
| S | | |
| | | |
| | Seconds, numeric, at least 2 digits | |
| | with leading 0 | |
| | | |
| | | |
| | 01, 03, 57 | |
| | | |
| | | |
| s | | |
| | | |
| | Seconds, numeric | |
| | | |
| | | |
| | 1, 3, 57 | |
| | | |
| | | |
| R | | |
| | | |
| | Sign " -" when negative, " +" when | |
| | positive | |
| | | |
| | | |
| | -, + | |
| | | |
| | | |
| r | | |
| | | |
| | Sign " -" when negative, empty when | |
| | positive | |
| | | |
| | | |
| | -, | |
| | | |
+------------------+--------------------------------------+---+
RETURN VALUES
Returns the formatted interval.
NOTES
Note
The DateInterval::format method does not recalculate carry over points in time strings nor in date segments. This is expected
because it is not possible to overflow values like "32 days" which could be interpreted as anything from "1 month and 4 days" to "1
month and 1 day".
EXAMPLES
Example #1
DateInterval example
<?php
$interval = new DateInterval('P2Y4DT6H8M');
echo $interval->format('%d days');
?>
The above example will output:
4 days
Example #2
DateInterval and carry over points
<?php
$interval = new DateInterval('P32D');
echo $interval->format('%d days');
?>
The above example will output:
32 days
Example #3
DateInterval and DateTime::diff with the %a and %d modifiers
<?php
$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);
// %a will output the total number of days.
echo $interval->format('%a total days')."
";
// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');
?>
The above example will output:
31 total days
1 month, 0 days
SEE ALSO
DateTime::diff.
PHP Documentation Group DATEINTERVAL.FORMAT(3)