EPOCH to real time?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users EPOCH to real time?
# 1  
Old 07-15-2006
EPOCH to real time?

hi all Smilie

i am wondering if there is a way to convert from EPOCH time to the standard tim, may be using a script or some thing else???????


thanks............................
# 2  
Old 07-15-2006
Code:
#!/usr/bin/perl -w
die "Usage: $0 seconds\n" unless scalar @ARGV;
print scalar localtime(shift),"\n";

# 3  
Old 07-15-2006
C example:
Code:
#include <time.h>
#include <stdio.h>

/******************************************************
*   to_real_date()
*   parms: sec  =epoch time
*          dest =string to store result
*          len  =len of string (# bytes) 
*   convert sec in epoch time to standard data & time        
*******************************************************/

char *to_real_date(char *dest, time_t sec, size_t len)
{
          /* %c format = std date and time */
	size_t result=strftime(dest,len,"%c",localtime(&sec));
	
	if(result==0)
	{
		*dest=0x0;
	}
	return dest; 
}

int main()
{
	char tmp[80]={0x0};
	
	printf("1111256774 seconds into the epoch = %s\n", to_real_date(tmp, 1111256774, 80));
	return 0;
}

It can also be done in perl, or on Linux using the date utility -- see info date
# 4  
Old 07-15-2006
if on Solaris:
Code:
echo "0t${currentEpoch}=Y" | /usr/bin/adb

# 5  
Old 07-18-2006
EPOCH on AIX

thans for all

but can i do it using shell scripting on AIX platform or i should use a programming language to do that????
# 6  
Old 07-18-2006
I don't know any direct method for getting the answer in AIX and doing it in a shell script will be complicated. Use C or Perl as per jim and hitori's posts.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: time intervals based on epoch time

I have a list of epoch times delimited by "-" as follows: 1335078000 - 1335176700 1335340800 - 1335527400 1335771300 - 1335945600 1336201200 - 1336218000 The corresponding dates are: 20120422 1000 - 20120423 1325 20120425 1100 - 20120427 1450 20120430 1035 - 20120502 1100 ... (3 Replies)
Discussion started by: alex2005
3 Replies

2. Shell Programming and Scripting

Converting real time to epoch time

# date +%s -d "Mon Feb 11 02:26:04" 1360567564 # perl -e 'print scalar localtime(1360567564), "\n";' Mon Feb 11 02:26:04 2013 the epoch conversion is working fine. but one of my application needs 13 digit epoch time as input 1359453135154 rather than 10 digit epoch time 1360567564... (3 Replies)
Discussion started by: vivek d r
3 Replies

3. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

4. Shell Programming and Scripting

how to convert date time to epoch time in solaris

Hi, Is there any easy way to convert date time(stored in shell variable ) to epoch time in solaris box? As +%s is working on linux but not on solaris, also -d option is not working. Any suggestion please? (6 Replies)
Discussion started by: anshuman0507
6 Replies

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

6. Shell Programming and Scripting

epoch time

Hi, i need to convert below date/time format into epoch time YYYY-m-d H:M below the example: a=`date +"%F %H:%M"` echo $a Convert $a to epoch time ------------------------------------------------------------------------ lets take an example if $a=1.03 here i want the epoch time... (3 Replies)
Discussion started by: ali560045
3 Replies

7. UNIX for Advanced & Expert Users

Epoch time

Guys, i have a question... I have 2 sets of data say "a" and "a+1" which has values in epoch time.. Question is... if i were to get the time difference where diff = "a+1" - "a" can i convert it back to real time duration after the subtraction... OR i need to convert em first before i do the... (2 Replies)
Discussion started by: 12yearold
2 Replies

8. Shell Programming and Scripting

Epoch time

Guys, i have a question... I have 2 sets of data say "a" and "a+1" which has values in epoch time.. Question is... if i were to get the time difference where diff = "a+1" - "a" can i convert it back to real time duration after the subtraction... OR i need to convert em first before i do the... (1 Reply)
Discussion started by: 12yearold
1 Replies
Login or Register to Ask a Question