* timestamp (unix time) @ 1998-12-02 5:00 Pedro Nobre 1998-12-02 5:00 ` Ed Wensell III aka THE StormRaiser 0 siblings, 1 reply; 5+ messages in thread From: Pedro Nobre @ 1998-12-02 5:00 UTC (permalink / raw) Hello all, I need to convert the unix time to a string. I already know that there is a c function (ctime) in a unix library (time.h) that does that. The problem is that i don't have a c compiler in my machine. Does anyone knows the algorithm to do that? Thanks. email: pmn@edinet.pt ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: timestamp (unix time) 1998-12-02 5:00 timestamp (unix time) Pedro Nobre @ 1998-12-02 5:00 ` Ed Wensell III aka THE StormRaiser 1998-12-02 5:00 ` Pedro Nobre 0 siblings, 1 reply; 5+ messages in thread From: Ed Wensell III aka THE StormRaiser @ 1998-12-02 5:00 UTC (permalink / raw) Pedro Nobre wrote: > > Hello all, > > I need to convert the unix time to a string. > I already know that there is a c function (ctime) in a unix library (time.h) > that does that. > The problem is that i don't have a c compiler in my machine. > Does anyone knows the algorithm to do that? So shall we assume you are making a shell script? In C-Shell, you could try: $ set DATE=`date` $ echo $DATE Wed Dec 2 08:29:09 EST 1998 In Bourne or Korn Shell: $ DATE=`date` $ echo $DATE Wed Dec 2 08:34:29 EST 1998 Check out the man pages on date to see how you can manipulate the date/time output format to suit your needs. Regardless of format, the output is in string unless otherwise conoluted. Now if I am missing what you are trying to do, please try to provide more info and someone else will probably take a crack at it... -- Until soon... Ed Wensell III Systems and Operations Support, Pellissippi State E-mail hint: A college with a dot net domain? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: timestamp (unix time) 1998-12-02 5:00 ` Ed Wensell III aka THE StormRaiser @ 1998-12-02 5:00 ` Pedro Nobre 1998-12-03 5:00 ` Jeffrey Mogul 1998-12-03 5:00 ` Boyd Adamson 0 siblings, 2 replies; 5+ messages in thread From: Pedro Nobre @ 1998-12-02 5:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1452 bytes --] Thanks, but that isn�t realy what i�m looking for. You are write, i'm making a shell script, but let me explain it better: Unix stores date in a long integer that represents the number of seconds since Jan,1,1970. What i pretend is something that decodes a number, say "912614795", to a date "02-12-1998 16:05:31" corresponding to that number. Pedro Ed Wensell III aka THE StormRaiser wrote in message <366542CE.7893@pstcc.cc.tn.us.net>... >Pedro Nobre wrote: >> >> Hello all, >> >> I need to convert the unix time to a string. >> I already know that there is a c function (ctime) in a unix library (time.h) >> that does that. >> The problem is that i don't have a c compiler in my machine. >> Does anyone knows the algorithm to do that? > >So shall we assume you are making a shell script? > >In C-Shell, you could try: > > $ set DATE=`date` > $ echo $DATE > Wed Dec 2 08:29:09 EST 1998 > >In Bourne or Korn Shell: > > $ DATE=`date` > $ echo $DATE > Wed Dec 2 08:34:29 EST 1998 > >Check out the man pages on date to see how you can manipulate the >date/time output format to suit your needs. Regardless of format, the >output is in string unless otherwise conoluted. > >Now if I am missing what you are trying to do, please try to provide >more info and someone else will probably take a crack at it... > >-- > >Until soon... >Ed Wensell III >Systems and Operations Support, Pellissippi State >E-mail hint: A college with a dot net domain? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: timestamp (unix time) 1998-12-02 5:00 ` Pedro Nobre @ 1998-12-03 5:00 ` Jeffrey Mogul 1998-12-03 5:00 ` Boyd Adamson 1 sibling, 0 replies; 5+ messages in thread From: Jeffrey Mogul @ 1998-12-03 5:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 745 bytes --] In article <743p02$8ps1@globo.edinfor.pt>, "Pedro Nobre" <pmn@edinet.pt> writes: |> Thanks, but that isn�t realy what i�m looking for. |> You are write, i'm making a shell script, but let me explain it better: |> Unix stores date in a long integer that represents the number of seconds |> since Jan,1,1970. |> What i pretend is something that decodes a number, say "912614795", to a |> date "02-12-1998 16:05:31" corresponding to that number. The GNU version of AWK, called "gawk", has a function named strftime() that does what you want. See "man gawk" for more details (and you will also have to do "man strftime" to find out how to get the format that you want. Then you can invoke gawk from your script - no compiler needed. -Jeff ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: timestamp (unix time) 1998-12-02 5:00 ` Pedro Nobre 1998-12-03 5:00 ` Jeffrey Mogul @ 1998-12-03 5:00 ` Boyd Adamson 1 sibling, 0 replies; 5+ messages in thread From: Boyd Adamson @ 1998-12-03 5:00 UTC (permalink / raw) To: Pedro Nobre Pedro Nobre wrote: > > Thanks, but that isn�t realy what i�m looking for. > You are write, i'm making a shell script, but let me explain it better: > Unix stores date in a long integer that represents the number of seconds > since Jan,1,1970. > What i pretend is something that decodes a number, say "912614795", to a > date "02-12-1998 16:05:31" corresponding to that number. > > Pedro Sounds like what you need is a program called unixSex, written by one of my colleagues. It will convert from time_t values (seconds from the epoch) to and from a date string, allowing you to specify a format string so the date can be in whatever format you want. Since you don't have a compiler, I can mail you an executable if you like. For example: titan:~$ unixSex -h Usage: To print seconds since the Epoch (01/01/1970) to stdout: unixSex To print seconds since the Epoch for a date string to stdout (default fmt-string: "%Y%m%d%H%M%S"; use %b, %B, %d, %H, %m, %M, %S, %y or %Y): unixSex "[date-str]" "[fmt-string]" The reverse: print time string (like output from 'date') to stdout: unixSex -v [seconds-since-Epoch] Same as the previous, allowing user-defined format (see 'man strftime'): unixSex -v [seconds-since-Epoch] "[fmt-string]" titan:~$ unixSex 912646323 titan:~$ unixSex -v 912646323 Thu Dec 03 10:52:03 AEST 1998 Or, more specifically to your question: titan:~$ unixSex -v 912614795 "%d-%m-%Y %H:%M:%S" 03-12-1998 02:06:35 titan:~$ Heh... I guess we're in different timezones. titan:~$ TZ=:GMT unixSex -v 912614795 "%d-%m-%Y %H:%M:%S" 02-12-1998 16:06:35 titan:~$ Boyd -- ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-12-03 5:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1998-12-02 5:00 timestamp (unix time) Pedro Nobre 1998-12-02 5:00 ` Ed Wensell III aka THE StormRaiser 1998-12-02 5:00 ` Pedro Nobre 1998-12-03 5:00 ` Jeffrey Mogul 1998-12-03 5:00 ` Boyd Adamson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox