convert a specific date to a unix timestamp


 
Thread Tools Search this Thread
Operating Systems AIX convert a specific date to a unix timestamp
# 1  
Old 03-09-2012
convert a specific date to a unix timestamp

hello,

i have an AIX5.3 machine and i am writing a script to display some processes.
inside the script i want to get the time that the process starts and convert it to a unix timestamp.
is there a command that i can use to do that? i search the web but all i found is long scripts and it does not help me.
also note that i cannot use
Code:
date -d

command or
Code:
mktime

function.
note that i am not asking how to find a command to get the process or the time of the process. i can get the start time of the process the point is to be able to convert the time to a unix timestamp.

thank you in advance
# 2  
Old 03-09-2012
Code:
 
perl -e 'print localtime;'

# 3  
Old 03-09-2012
this command doesnt seem to work for me.
i am using
Code:
echo <timestamp> | perl -e 'print localtime(<>) . "\n";'

to convert the timestamp into a human date.
but now i want to do the opposite, meaning converting a specific date into unix timestamp
# 4  
Old 03-09-2012
Please post an example and explain in detail what you mean by a "unix timestamp".

The best time to record when a process starts is in the script you originally used to start the process.
Reading between the lines, it is quite difficult to work from the output from "ps".
# 5  
Old 03-12-2012
by unix timestamp i mean the following:
when you run the command
Code:
date +%s

you have an output of an integer. this integer is the unix timestamp in my case. but also in my script i want to get this output by providing any given date. if i run
Code:
date +%s

i get the timestamp of the current date and time. i want to input a time to my script and the script display the timestamp of the time that i provided.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Timestamp in text to Serial Date-Time

Hi, I have a data file where the timestamp is in the style of: 2016-10-11 07:01:23.375-500 which is yyyy-mm-dd hh-mm-ss-000 then time conversion from UTC What i need to do is convert these timestamps from the above format to a the Serial Date format (i.e 42,654.2920446 ) now.. if... (14 Replies)
Discussion started by: AshBax
14 Replies

2. Shell Programming and Scripting

Convert date in dd mm yyyy format to UNIX timestamp

Hello All, I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following: date -d $mydate +%s where mydate = 23/12/2016 00:00:00 I am getting following error: date: extra operand `+%s' Try `date --help' for more information. ... (1 Reply)
Discussion started by: angshuman
1 Replies

3. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

4. Shell Programming and Scripting

Convert UNIX timestamp to readable format in the file

Hello I have a file : file1.txt with the below contents : 237176 test1 test2 1442149024 237138 test3 test4 1442121300 237171 test5 test7 1442112823 237145 test9 test10 1442109600 In the above file fourth field represents the timestamp in Unix format. I found a command which converts... (6 Replies)
Discussion started by: rahul2662
6 Replies

5. UNIX for Dummies Questions & Answers

How to convert R$Timestamp in Sql*Plus within a UNIX Shell Script?

I need to compare a R$Timestamp field sql within a Unix Shell Script. In straight SQL the following code works fine: Table Name: LL_UNIT_TRANSACTION UT Field: R$Timestamp Where TRUNC(UT.R$Timestamp) >= TRUNC(SYSDATE -7) the following returns no data within the Unix Shell Script... (2 Replies)
Discussion started by: Dapconsult
2 Replies

6. Shell Programming and Scripting

How to convert date and timestamp?

Hi, I have a file file1 having data as below 20110501,070742, ,012345678909,09999999999,68.5, 20110501,070236, ,089375855455,09376383333,374.3, 20110501,070525, ,090345895555,08444233444,206.2, 20110501,230051, ,000934744433,07624262223,480.1, First field is date(YYYYMMDD) and second... (5 Replies)
Discussion started by: vsachan
5 Replies

7. AIX

Change specific (not current) date to timestamp

Hello to all. I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this: Tue Mar 29 06:59:00... (5 Replies)
Discussion started by: Hyperborejac
5 Replies

8. Shell Programming and Scripting

To convert a date(in string format) to unix timestamp

Hi All, I have a string like below. "Mar 31 2009" . I want to convert this to unix time . Also please let me know how to find the unix time for the above string minus one day. For Eg. if i have string "Mar 31 2009" i want to find the unix time stamp of "Mar 30 2009". Thanks in advance,... (11 Replies)
Discussion started by: girish.raos
11 Replies

9. Shell Programming and Scripting

Convert Unix Timestame to real timestamp

Hello, Did anyone know how to use script (e.g. perl) to conver Unix Timestame to real timestame in GMT+8 ? 1245900787 file:/tmp/a/Test/.txt.swp has created 1245900988 file:/tmp/a/Test/.txt.swp has changed Thu, 25 Jun 2009 11:33:07 GMT+8 file:/tmp/a/Test/.txt.swp has created Thu, 25 Jun... (4 Replies)
Discussion started by: happyday
4 Replies

10. Shell Programming and Scripting

how to convert from timestamp to date format in tcsh

hello all im looking for fast way to convert timestamp format to date format and vaiseversa in tcsh , can it be done? thanks allot (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question