Sponsored Content
Top Forums Shell Programming and Scripting How to convert string(variable) into date( epoch) in ksh on HPUX machine? Post 302702085 by Rashu123 on Tuesday 18th of September 2012 01:00:12 AM
Old 09-18-2012
To be more specific, in bash

TMRW_DATE=`date --date="$DATE" +"%s"`

where 'date --date' is converting the string $DATE into its epoch time (in sec) but in ksh there is no such option with date.

As another limitation I can't download ksh93 or any higher version.I'm currently having ksh88 installed in HPUX machine .If its not possible in ksh script then can i accomplish it using any perl script?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert date into epoch in Perl on Solaris

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)
Discussion started by: pavanlimo
3 Replies

2. Shell Programming and Scripting

Convert value stored in a variable to epoch time?

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)
Discussion started by: Glyn_Mo
2 Replies

3. Shell Programming and Scripting

Need to convert an epoch date to MMDDYYHHmm format

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)
Discussion started by: LetsGoPens
4 Replies

4. Shell Programming and Scripting

Convert epoch to human readable date & time format

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)
Discussion started by: Yaminib
3 Replies

5. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

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)
Discussion started by: minigts
5 Replies

6. Shell Programming and Scripting

Convert epoch time to Julian date

Need assistance in converting an epoch time to Julian date To get epoch perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"' (3 Replies)
Discussion started by: ajayram_arya
3 Replies

7. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

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)
Discussion started by: raj48
7 Replies

8. Shell Programming and Scripting

Convert a future date into epoch seconds on HPUX system

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)
Discussion started by: veeresh_15
5 Replies

9. Shell Programming and Scripting

Convert a string to epoch time

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)
Discussion started by: Girish19
1 Replies

10. Shell Programming and Scripting

Convert Second Column Date Into EPOCH Time And Print Complete Row

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
DATE(1) 						    BSD General Commands Manual 						   DATE(1)

NAME
date -- display or set date and time SYNOPSIS
date [-ajnu] [-d date] [-r seconds] [+format] [[[[[[CC]yy]mm]dd]HH]MM[.SS]] DESCRIPTION
date displays the current date and time when invoked without arguments. Providing arguments will format the date and time in a user-defined way or set the date. Only the superuser may set the date. The options are as follows: -a Use adjtime(2) to change the local system time slowly, maintaining it as a monotonically increasing function. -a implies -n. -d date Parse the provided human-described date and time and display the result without actually changing the system clock. (See parsedate(3) for examples.) -j Parse the provided canonical representation of date and time (described below) and display the result without actually changing the system clock. -n The utility timed(8) is used to synchronize the clocks on groups of machines. By default, if timed is running, date will set the time on all of the machines in the local group. The -n option stops date from setting the time for other than the current machine. -r seconds Print out the date and time that is seconds from the Epoch. -u Display or set the date in UTC (universal) time. An operand with a leading plus (+) sign signals a user-defined format string which specifies the format in which to display the date and time. The format string may contain any of the conversion specifications described in the strftime(3) manual page, as well as any arbitrary text. A <newline> character is always output after the characters specified by the format string. The format string for the default display is: %a %b %e %H:%M:%S %Z %Y If an operand does not have a leading plus sign, it is interpreted as a value for setting the system's notion of the current date and time. The canonical representation for setting the date and time is: CC The first two digits of the year (the century). yy The second two digits of the year. If yy is specified, but CC is not, a value for yy between 69 and 99 results in a CC value of 19. Otherwise, a CC value of 20 is used. mm The month of the year, from 01 to 12. dd The day of the month, from 01 to 31. HH The hour of the day, from 00 to 23. MM The minute of the hour, from 00 to 59. SS The second of the minute, from 00 to 61. Everything but the minutes is optional. Time changes for Daylight Saving and Standard time and leap seconds and years are handled automatically. ENVIRONMENT
The following environment variables affect the execution of date: TZ The timezone to use when displaying dates. See environ(7) for more information. FILES
/etc/localtime Symlink pointing to system's default timezone information file in /usr/share/zoneinfo directory. /var/log/wtmp A record of date resets and time changes. /var/log/messages A record of the user setting the time. EXAMPLES
The command: date '+DATE: %m/%d/%y%nTIME: %H:%M:%S' will display: DATE: 11/21/87 TIME: 13:36:16 The command: date 8506131627 sets the date to ``June 13, 1985, 4:27 PM''. The command: date 1432 sets the time to 2:32 PM, without modifying the date. DIAGNOSTICS
Exit status is 0 on success, 1 if unable to set the date, and 2 if able to set the local date, but unable to set it globally. Occasionally, when timed(8) synchronizes the time on many hosts, the setting of a new time value may require more than a few seconds. On these occasions, date prints: 'Network time being set'. The message 'Communication error with timed' occurs when the communication between date and timed fails. SEE ALSO
adjtime(2), gettimeofday(2), settimeofday(2), parsedate(3), strftime(3), utmp(5), timed(8) R. Gusella and S. Zatti, TSP: The Time Synchronization Protocol for UNIX 4.3BSD. STANDARDS
The date utility is expected to be compatible with IEEE Std 1003.2 (``POSIX.2''). BSD
November 15, 2006 BSD
All times are GMT -4. The time now is 09:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy