The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
epoch time ali560045 Shell Programming and Scripting 3 06-02-2008 01:41 AM
epoch time in shell script robsonde SUN Solaris 12 04-07-2008 08:04 PM
Get real value from real-time systems iBot Complex Event Processing RSS News 0 01-13-2008 10:10 PM
Epoch time 12yearold UNIX for Advanced & Expert Users 2 07-14-2006 12:11 PM
Epoch time 12yearold Shell Programming and Scripting 1 07-14-2006 08:57 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-15-2006
Registered User
 

Join Date: Apr 2006
Location: Iraq
Posts: 34
Stumble this Post!
EPOCH to real time?

hi all

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............................
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-15-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 356
Stumble this Post!
Code:
#!/usr/bin/perl -w
die "Usage: $0 seconds\n" unless scalar @ARGV;
print scalar localtime(shift),"\n";
Reply With Quote
  #3 (permalink)  
Old 07-15-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,854
Stumble this Post!
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
Reply With Quote
  #4 (permalink)  
Old 07-15-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
if on Solaris:
Code:
echo "0t${currentEpoch}=Y" | /usr/bin/adb
Reply With Quote
  #5 (permalink)  
Old 07-18-2006
Registered User
 

Join Date: Apr 2006
Location: Iraq
Posts: 34
Stumble this Post!
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????
Reply With Quote
  #6 (permalink)  
Old 07-18-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
Stumble this Post!
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0