Solaris 10 doesn't seem to like me a lot. I am trying to run a simple script to accept date and return epoch of that date:
#!/usr/bin/perl -w
use strict;
use Time::ParseDate;
my($date1)="Mon Mar 27 05:54:08 CDT 2009";
chomp $date1;
#Convert to seconds since start of epoch
my $time1 =... (3 Replies)
Hello
I have a the creation date of a file stored in a variable in the following format:
Wed May 06 10:14:58 2009Is there a way I can echo the variable and display it in epoch time?
I've done a lot of searching on this topic, but haven't managed to get a solution. I'm on Solaris 10.
... (2 Replies)
System: HP-UX
Kornshell
Perl is installed, but not POSIX
Hello,
I am calculating a future date/time. To do this I take the system date in epoch format and add to it. I now need to take the new epoch date and convert it to MMDDYYHHmm format.
Any help with this is greatly appreciated. (4 Replies)
Hello
I have log file from solaris system which has date field converted by Java application using System.currentTimeMillis() function, example is 1280943608380 which equivalent to GMT: Wed, 04 Aug 2010 17:40:08 GMT.
Now I need a function in shell script which will convert 1280943608380... (3 Replies)
Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do.
What am I trying to do?
I need to take the time value in epoch format returned from the... (5 Replies)
I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date
#!/usr/bin/ksh
set -x
for s in server ; do
ssh -T $s <<-EOF
from_date="12-Jan-2015 12:02:09"
to_date="24-Jan-2015 13:02:09"
echo \$from_date
echo... (7 Replies)
Hi All,
I have scenario where i have to compare two dates.
I thought of converting them to epoch seconds and do a numeric comparison.
This works fine on Linux systems.
$ date -d '2015/12/31' +%s
1451538000
$ date +%s
1449159121
But we don't have -d option in HPUX.
What would be... (5 Replies)
Team,
I am working on a shell script and i am extracting a date string in "SunOS server" with below format.
Mon Jan 21 04:13:48 EST 2021
Can you please assist me the best way to convert the extracted string to epoch time like "date +%s" in Linux.
Thanks in advance (1 Reply)
Hello Team,
I am stuck in getting the required output in the following case. Please help.
My input file is
aa|08/01/2016
bb|08/15/2016
I wish to convert the file into
aa|epoch time
bb|epoch time
I am using following code: (3 Replies)
Discussion started by: angshuman
3 Replies
LEARN ABOUT REDHAT
date::parse
Date::Parse(3) User Contributed Perl Documentation Date::Parse(3)NAME
Date::Parse - Parse date strings into time values
SYNOPSIS
use Date::Parse;
$time = str2time($date);
($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
DESCRIPTION
"Date::Parse" provides two routines for parsing date strings into time values.
str2time(DATE [, ZONE])
"str2time" parses "DATE" and returns a unix time value, or undef upon failure. "ZONE", if given, specifies the timezone to assume when
parsing if the date string does not specify a timezome.
strptime(DATE [, ZONE])
"strptime" takes the same arguments as str2time but returns an array of values "($ss,$mm,$hh,$day,$month,$year,$zone)". Elements are
only defined if they could be extracted from the date string. The $zone element is the timezone offset in seconds from GMT. An empty
array is returned upon failure.
MULTI-LANGUAGE SUPPORT
Date::Parse is capable of parsing dates in several languages, these are English, French, German and Italian. Changing the language is done
via a static method call, for example
Date::Parse->language('German');
will cause Date::Parse to attempt to parse any subsequent dates in German.
This is only a first pass, I am considering changing this to be
$lang = Date::Language->new('German');
$lang->str2time("25 Jun 1996 21:09:55 +0100");
I am open to suggestions on this.
EXAMPLE DATES
Below is a sample list of dates that are known to be parsable with Date::Parse
1995:01:24T09:08:17.1823213 ISO-8601
1995-01-24T09:08:17.1823213
Wed, 16 Jun 94 07:29:35 CST Comma and day name are optional
Thu, 13 Oct 94 10:13:13 -0700
Wed, 9 Nov 1994 09:50:32 -0500 (EST) Text in ()'s will be ignored.
21 dec 17:05 Will be parsed in the current time zone
21-dec 17:05
21/dec 17:05
21/dec/93 17:05
1999 10:02:18 "GMT"
16 Nov 94 22:28:20 PST
BUGS
When both the month and the date are specified in the date as numbers they are always parsed assuming that the month number comes before
the date. This is the usual format used in American dates.
The reason why it is like this and not dynamic is that it must be deterministic. Several people have suggested using the current locale,
but this will not work as the date being parsed may not be in the format of the current locale.
My plans to address this, which will be in a future release, is to allow the programmer to state what order they want these values parsed
in.
AUTHOR
Graham Barr <gbarr@pobox.com>
COPYRIGHT
Copyright (c) 1995 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
perl v5.8.0 2002-06-06 Date::Parse(3)