The perl script i use is as below and works fine but i guess im just being curious as to whether there was an easier way in shell without using GNU date or perl
how can we add or subtract days from the output of date command in unix...
like if i want to subtract a day from the result of date command like this..
v_date=`date +%Y%m%d`
this wud give me 20080519
now i want to subtract one day from this.. so tht it wud give me 20080518..
how do i do... (1 Reply)
Hello Unix gurus,
I need to add days to the input date and further use it in comparision with the existing date.
Im having issues sto add days to date,can you guys help me with script or function with which I can add days to the date.
Thanks,
Sud (10 Replies)
Hi,
Anybody knows how to get what date was 28 days ago of the current system date through UNIX script.
Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Hi,
I'm writing an batch file to create report
In the batch file iam passing two arguments:startdate and finishdate
Ex: startdate=07-sep-2009 finishdate=07-sep-2011
I need to have script that takes command line argument as input and gives me out currentdate last year and current date... (2 Replies)
I am trying to find out the number of days between the current date and user defined date.
I took reference from here for the date2jd() function.
Modified the function according to my requirement. But its not working properly.
Original code from here is working fine.
#!/bin/sh... (1 Reply)
Hi! I am trying to read a file and every line has a specific date as one of its fields.
I want to take that date and compare it to the date today plus 6 days.
while read line
do
date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD
if ; then
...proceed commands
... (1 Reply)
Hi,
One of my Unix scripts needs to look for files coming in on Fridays. This script runs on Mondays. $date +"%y%m%d" will give me today's date. How can I get previous Friday's date.. can I do "today's date minus 3 days" to get Friday's date? If not, then any other way?? Name of the files is... (4 Replies)
current date command runs well
awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
subtract 30 days fails
awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
LEARN ABOUT PHP
px_timestamp2string
PX_TIMESTAMP2STRING(3)PX_TIMESTAMP2STRING(3)px_timestamp2string - Converts the timestamp into a string.SYNOPSIS
string px_timestamp2string (resource $pxdoc, float $value, string $format)
DESCRIPTION
Turns a timestamp as it stored in the paradox file into human readable format. Paradox timestamps are the number of miliseconds since
0001-01-02. This function is just for convenience. It can be easily replaced by some math and the calendar functions as demonstrated in the
following example.
PARAMETERS
o $pxdoc
- Resource identifier of the paradox database.
o $value
- Value as stored in paradox database field of type PX_FIELD_TIME, or PX_FIELD_TIMESTAMP.
o $format
- String format similar to the format used by date(3). The placeholders support by this function is a subset of those supported by
date(3) (Y, y, m, n, d, j, H, h, G, g, i, s, A, a, L).
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Turn a paradox timestamp into a human readable form
<?php
$px = px_new();
/* make up a date as it could be stored in */
/* a date field of a paradox db. */
/* 700000 days since 1.1.0000. */
$days = 700000;
/* Use the calendar functions to print a */
/* human readable format of the date */
echo jdtogregorian($days+1721425)."
";
/* Turn it into a timestamp as it stored in a paradox database */
/* Timestamps are stored in miliseconds since 0001-01-02 */
$stamp = $days * 86400.0 * 1000.0;
/* Add one hour */
$stamp += 3600000.0;
/* The following will output '7/15/1917 01:00:00'. */
echo px_timestamp2string($px, $stamp, "n/d/Y H:i:s")."
";
px_delete($px);
?>
The above example will output:
7/15/1917
7/15/1917 01:00:00
The Julian day count as passed to jdtogregorian(3) has a different base of 1.1.4714 b.c. and must therefore be calculated by adding
1721425 to the day count used in the paradox file. Turning the day count into a timestamp is easily done by multiplying with 86400000.0 to
obtain miliseconds.
SEE ALSO px_date2string(3), jdtogregorian(3).
PHP Documentation Group PX_TIMESTAMP2STRING(3)