hi,
for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format.
i checked the datecalc and other scripts but couldnt modify them to cater to my need:(...
The datecalc gives an output which i believe is the total days till that date, but i want to convert it... (2 Replies)
Hi All,
Need your help in converting a date format in ksh.
I'm currently working on SUN os where my script is getting a date from a table.
The result returns to ksh in this format: 17-JUL-08
How do i convert this string to a date format like yyyymmdd?
I tried #!/bin/ksh
d="17-JUL-08"... (5 Replies)
I have a file named "suspected" with series of line like these :
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent... (3 Replies)
I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column.
I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this?
Sample input
02/27/09,23:52:31
02/27/09,23:52:52... (3 Replies)
Dear Expert
How to convert date in format of YYYY-MM-DD HH:MM:SS to unix format
using a script or command if avaliable
Example
"2011-05-15 18:00:00" is converted to 1330970400
I tried to use option d in date command but no use, Im using solaris 10
Thanks a lot (12 Replies)
I've been using this thread:
https://www.unix.com/shell-programming-scripting/58675-change-date-dd-mmm-yyyy-mm-dd-yyyy.html
and
https://www.unix.com/shell-programming-scripting/14655-changing-yyyy-mm-dd-ddmmyy.html
and this code:
on this format:
05/16/2008 18:30:49 Installation 48985and I'm... (3 Replies)
How can I convert any user inputted date into yyyy/mm/dd ?
For example user can input date one of the following 20120121 , 2012-01-21 ,01/21/2012,01/21/2012 etc
But I need to convert any of the date entered by user into yyyy/mm/dd (2012/01/2012). Any suggestion. Thanks in advance
this is... (1 Reply)
Could you tell me how to convert the following dates?
If I have m/d/yyyy, I want to have
0m/0d/yyyy. I want my dates to always be 8 digits.
In other words, I want a 0 inserted whenever the month or day is a single digit.
My issue is first I need to use FS="," to get field $4 for the... (7 Replies)
Hi,
I am getting the below string as a input for date.
12/03/2013 11:02 AM
I want to change this date as 03-DEC-2013 11:02 AM.
Could you please help on this.
Thanks
Chelladurai (4 Replies)
Hi guys
I am looking to convert this kind of entry in a txt file
26/04/2008
to
April 2008
Note : this is not using the date command , these are date entries in a file
can i do this with sed ?
Use code tags, thanks. (5 Replies)
Discussion started by: johnnybananas
5 Replies
LEARN ABOUT REDHAT
time::local
Time::Local(3pm) Perl Programmers Reference Guide Time::Local(3pm)NAME
Time::Local - efficiently compute time from local and GMT time
SYNOPSIS
$time = timelocal($sec,$min,$hour,$mday,$mon,$year);
$time = timegm($sec,$min,$hour,$mday,$mon,$year);
DESCRIPTION
These routines are the inverse of built-in perl functions localtime() and gmtime(). They accept a date as a six-element array, and return
the corresponding time(2) value in seconds since the Epoch (Midnight, January 1, 1970). This value can be positive or negative.
It is worth drawing particular attention to the expected ranges for the values provided. The value for the day of the month is the actual
day (ie 1..31), while the month is the number of months since January (0..11). This is consistent with the values returned from local-
time() and gmtime().
The timelocal() and timegm() functions perform range checking on the input $sec, $min, $hour, $mday, and $mon values by default. If you'd
rather they didn't, you can explicitly import the timelocal_nocheck() and timegm_nocheck() functions.
use Time::Local 'timelocal_nocheck';
{
# The 365th day of 1999
print scalar localtime timelocal_nocheck 0,0,0,365,0,99;
# The twenty thousandth day since 1970
print scalar localtime timelocal_nocheck 0,0,0,20000,0,70;
# And even the 10,000,000th second since 1999!
print scalar localtime timelocal_nocheck 10000000,0,0,1,0,99;
}
Your mileage may vary when trying these with minutes and hours, and it doesn't work at all for months.
Strictly speaking, the year should also be specified in a form consistent with localtime(), i.e. the offset from 1900. In order to make
the interpretation of the year easier for humans, however, who are more accustomed to seeing years as two-digit or four-digit values, the
following conventions are followed:
o Years greater than 999 are interpreted as being the actual year, rather than the offset from 1900. Thus, 1963 would indicate the year
Martin Luther King won the Nobel prize, not the year 2863.
o Years in the range 100..999 are interpreted as offset from 1900, so that 112 indicates 2012. This rule also applies to years less than
zero (but see note below regarding date range).
o Years in the range 0..99 are interpreted as shorthand for years in the rolling "current century," defined as 50 years on either side of
the current year. Thus, today, in 1999, 0 would refer to 2000, and 45 to 2045, but 55 would refer to 1955. Twenty years from now, 55
would instead refer to 2055. This is messy, but matches the way people currently think about two digit dates. Whenever possible, use
an absolute four digit year instead.
The scheme above allows interpretation of a wide range of dates, particularly if 4-digit years are used.
Please note, however, that the range of dates that can be actually be handled depends on the size of an integer (time_t) on a given plat-
form. Currently, this is 32 bits for most systems, yielding an approximate range from Dec 1901 to Jan 2038.
Both timelocal() and timegm() croak if given dates outside the supported range.
IMPLEMENTATION
These routines are quite efficient and yet are always guaranteed to agree with localtime() and gmtime(). We manage this by caching the
start times of any months we've seen before. If we know the start time of the month, we can always calculate any time within the month.
The start times are calculated using a mathematical formula. Unlike other algorithms that do multiple calls to gmtime().
timelocal() is implemented using the same cache. We just assume that we're translating a GMT time, and then fudge it when we're done for
the timezone and daylight savings arguments. Note that the timezone is evaluated for each date because countries occasionally change their
official timezones. Assuming that localtime() corrects for these changes, this routine will also be correct.
BUGS
The whole scheme for interpreting two-digit years can be considered a bug.
The proclivity to croak() is probably a bug.
perl v5.8.0 2002-06-01 Time::Local(3pm)