getting the current time in Epoch format


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers getting the current time in Epoch format
# 1  
Old 05-12-2010
Computer getting the current time in Epoch format

Hi everybody,

I want to get the current time in epoch format (in UNIX or Korn Shell) and store it in a variable called
currentTime. Any response will be highly appreciatedSmilie

Thanks in advance,
omoyneSmilie
# 2  
Old 05-12-2010
Check this post...

get unix timestamp
# 3  
Old 05-12-2010
thanks but I was looking for something more straightforward Smilie
# 4  
Old 05-12-2010
I don't get your confusion...you'd asked basically the same question the other day (ie, https://www.unix.com/shell-programmin...#post302420128) and we gave you means to get both current time epoch value, and then the file stats off of a given file/directory...

???
# 5  
Old 05-12-2010
that was timestamp of a FILE!....this question is regard to obtaining the current time in epoch format. There are no files here!!
# 6  
Old 05-12-2010
Tools What about this?

Code:
touch file3
echo `stat -c%Y file3`
1273684993

the echo is above because I often actually use
Code:
time_var=$(echo `stat -c%Y file3`)
echo $time_var


Last edited by joeyg; 05-12-2010 at 02:35 PM.. Reason: reason for echo
# 7  
Old 05-12-2010
There are no date-related commands in ksh.
It would have to be an external utility or a custom program.

What Operating System are you running?



Code:
If you have Perl.

currentTime=$(perl -e 'print time;')

Which is also in the link posted in current thread as:

currentTime=$(perl -e "print time();")

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting a random epoch time into a readable format

I am trying to create a script that will take epoch (input from command line) and convert it into a readable format in bash/shell ---------- Post updated at 08:03 PM ---------- Previous update was at 07:59 PM ---------- #!bin/bash read -p "Please enter a number to represent epoch time:"... (9 Replies)
Discussion started by: sprocket
9 Replies

2. Shell Programming and Scripting

Convert epoch time stamp into human readable format

Can someone help me to write a shell script to convert epoch timestamp into human readable format 1394553600,"test","79799776.0","19073982.728571","77547576.0","18835699.285714" 1394553600,"test1","80156064.0","19191275.014286","62475360.000000","14200554.720000"... (10 Replies)
Discussion started by: Moon1234
10 Replies

3. Shell Programming and Scripting

Current triggered time to epoch seconds

I have a requirement to find long running instances for notifying the stake holders based on the triggered time in AIX. I am not sure how to convert the triggered time to epoch seconds. For example : Current triggered time of instance is 13:06:19 -> how to convert this into epoch in the... (5 Replies)
Discussion started by: chandu123
5 Replies

4. Shell Programming and Scripting

Report the current time in Binary format

Hey fellas, I am trying to report the current time in a binary format which is overwriting every second. So far I wrote following script which I know looks stupid since I'm a newbie! ;) #!/bin/bash while true; do clear; date | awk '{print $4}' | awk -F ":" '{print... (4 Replies)
Discussion started by: @man
4 Replies

5. Shell Programming and Scripting

converting epoch time to ddmmyy format

I can not find a working script or way to do this on sun solaris , can someone please guide me? e.g 1327329935 epoch secs = 012312 (ddmmyy) thanks (5 Replies)
Discussion started by: aliyesami
5 Replies

6. 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

7. 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

8. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

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

10. Shell Programming and Scripting

how to convert epoch time to readible format?

Hi, I would like to convert epoch time from the logs to readible fromat. How do I do it within shell? Thanks! (11 Replies)
Discussion started by: cin2000
11 Replies
Login or Register to Ask a Question