10-29-2011
Get Previous date from a given date
Hi all,
I have a variable where it has a date value in the format YYYY-MM-DD
eg->
pcontromModate="2010-11-31"
How can i get the previous date of pcontromModate in the format YYYY-MM-DD
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
How to find a date which is 7 days from the current date as well as how to find a date which is 7 days before this current date.
Urgently i need help.
Thanks in Advance
Regards
Arunava (2 Replies)
Discussion started by: arunava_maity
2 Replies
2. Shell Programming and Scripting
Hi,
I am trying to modify a script which accepts date in format dd/mm/yy. I am trying to modify the script so that it retrieves the date that was 15 days earlier from today as start date. Eg.if today is 05/09/2006, the script should retrieve 21/08/2006 as start date. Is there any script/code to... (2 Replies)
Discussion started by: ritzwan0
2 Replies
3. Shell Programming and Scripting
I want to get previous date from date command. I am using ksh shell.
Exmp:
today is 2008.09.04
I want the result : 2008.09.03
Please help.
Thanks in advance. (4 Replies)
Discussion started by: rinku
4 Replies
4. Shell Programming and Scripting
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)
Discussion started by: vigdmab
2 Replies
5. Shell Programming and Scripting
Hi guys,
I had a scenario...
1. I had to get the previous days date in yyyymmdd format
2. i had to create a file with Date inthe format yyyymmdd.txt format
both are different
thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies
6. Shell Programming and Scripting
Hi all,
I have a variable where it has a past date value in the format YYYY-MM-DD
eg->
pcontromModate="2008-11-31"
How can i get the date 1 day before the pcontromModate.
The required date is 2008-11-30. ..Plz reply since its an urgent one (2 Replies)
Discussion started by: morbid_angel
2 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
Hello:
I am bit puzzled with what I could be doing wrong and any help is appreciated.
I have a date in YYYMMDD format and I need to find the previous date. Based on the input on this forum, I have come up with the following. It seems to work for all except the following. Here I am passing date... (3 Replies)
Discussion started by: wincrazy
3 Replies
9. Shell Programming and Scripting
hi all,
need a script or command to get the previous date for the given input date...
like in my script i will pass date as input parameter like 2014-12-01 and i want the output as previous date.. ie.. 2014-11-30 (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
10. Shell Programming and Scripting
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
EREG(3) 1 EREG(3)
ereg - Regular expression match
SYNOPSIS
int ereg (string $pattern, string $string, [array &$regs])
DESCRIPTION
Searches a $string for matches to the regular expression given in $pattern in a case-sensitive way.
Warning
This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
PARAMETERS
o $pattern
- Case sensitive regular expression.
o $string
- The input string.
o $regs
- If matches are found for parenthesized substrings of $pattern and the function is called with the third argument $regs, the
matches will be stored in the elements of the array $regs. $regs[1] will contain the substring which starts at the first left
parenthesis; $regs[2] will contain the substring starting at the second, and so on. $regs[0] will contain a copy of the complete
string matched.
RETURN VALUES
Returns the length of the matched string if a match for $pattern was found in $string, or FALSE if no matches were found or an error
occurred.
If the optional parameter $regs was not passed or the length of the matched string is 0, this function returns 1.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 4.1.0 | |
| | |
| | Up to (and including) PHP 4.1.0 $regs will be |
| | filled with exactly ten elements, even though |
| | more or fewer than ten parenthesized substrings |
| | may actually have matched. This has no effect on |
| | ereg(3)'s ability to match more substrings. If no |
| | matches are found, $regs will not be altered by |
| | ereg(3). |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
ereg(3) example
The following code snippet takes a date in ISO format (YYYY-MM-DD) and prints it in DD.MM.YYYY format:
<?php
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";
} else {
echo "Invalid date format: $date";
}
?>
NOTES
Note
As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED
notice. See the list of differences for help on converting to PCRE.
Tip
ereg(3) is deprecated as of PHP 5.3.0. preg_match(3) is the suggested alternative to this function.
SEE ALSO
eregi(3), ereg_replace(3), eregi_replace(3), preg_match(3), strpos(3), strstr(3), quotemeta(3).
PHP Documentation Group EREG(3)