The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

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 04:41 AM
EPOCH to real time? TheEngineer UNIX for Advanced & Expert Users 5 07-18-2006 08:30 AM
Epoch time 12yearold UNIX for Advanced & Expert Users 2 07-14-2006 03:11 PM
Epoch time 12yearold Shell Programming and Scripting 1 07-14-2006 11:57 AM
Convert from standard epoch time from a shell script? LordJezo Shell Programming and Scripting 4 09-18-2005 11:48 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 04-06-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
If your date version support these options you can try this:

Code:
date +%s -d "01/01/2000 00:00:00"
Regards
  #9 (permalink)  
Old 04-06-2008
McLan McLan is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 21
Smile

HTML Code:
date +%s, doesn't work, I tried with %S (not %s),  date +%S , this gives the seconds but not epoch 

Do we have any other options with perl or nawk.
Btw, I am on Solarid
  #10 (permalink)  
Old 04-06-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Not too pretty, but pretty quick...

Code:
$ touch -t 200001010000.00 somefile
$ perl -e 'printf "%d\n", ((stat(shift))[9]); ' somefile
946702800
$ perl -e 'print scalar localtime(shift),"\n"' 946702800
Sat Jan  1 00:00:00 2000
$
1) touch a file to get the desired timestamp
2) use perl to display that timestamp in seconds
3) to verify, I use perl to convert unix internal time to human readable
  #11 (permalink)  
Old 04-06-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
/usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}'
  #12 (permalink)  
Old 04-06-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
vgersh99 - that is a very cool solution!

Code:
perl -e 'use Time::Local; print timelocal("00","00","00","01","01","2000"),"\n";'

Last edited by fpmurphy; 04-06-2008 at 06:39 PM..
  #13 (permalink)  
Old 04-07-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
The Solaris dtrace facility can also display the seconds since Epoch.

Code:
#!/usr/sbin/dtrace -qs

tick-1sec
{
        printf("%d seconds since the epoch\n", `time);
        exit(0)
}
  #14 (permalink)  
Old 05-12-2009
saurabhverma saurabhverma is offline
Registered User
  
 

Join Date: May 2009
Posts: 1
Example , To translate Tuesday may 12 2009 15:47:04 to epoch seconds . in PST zone

TZ=PST date -d "20090512 15:47:04" +%s
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0