LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 05-24-2007, 07:52 AM   #1
gbratig
LQ Newbie
 
Registered: Jun 2006
Posts: 14

Rep: Reputation: 0
Question Convert Normal Date to Unix Time


Hello, i need some help, i'm creating a script and i need to convert normal date (24/05/07) in unix time, i see some web sites with calculators, but i need to put the code in my shell script. In the first time i thought that i will found that in google jeje, but i only found the inverse, unix time to normal date. Somebody can help me?. Thanks a lot.
 
Old 05-24-2007, 08:32 AM   #2
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
After a quick google, I found the following page that should point you in the right direction, using perl...

http://www.unixreview.com/documents/s=1344/ur0307g/
 
Old 05-30-2007, 11:06 AM   #3
mudman69
Member
 
Registered: Mar 2007
Distribution: Whatever Works
Posts: 44

Rep: Reputation: 16
Hey gbratig, Can you point me to the site where you saw the Epoch to normal date conversion?
 
Old 05-31-2007, 01:32 AM   #4
gbratig
LQ Newbie
 
Registered: Jun 2006
Posts: 14

Original Poster
Rep: Reputation: 0
http://unixepoch.com/
 
Old 06-01-2007, 09:37 AM   #5
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
compile this and call it from your script. You'll have to setup a template file, you can probably create it in your script and delete it before the script finishes.
Code:
#include <stdio.h>
#include <time.h>

main( int argc, char * argv[] )
{
   struct tm * timestruct;
   time_t epochtime;

   if ( getenv("DATEMSK") == 0 )
   {
      printf("\nSet environment variable DATEMSK to\n");
      printf("the file containing the date templates\n");
      printf("see 'man 3 getdate'\n\n");
      exit(-1);
   }

   if ( argc > 1 )
   {
      timestruct = getdate(argv[1]);
      epochtime = mktime( timestruct );
      printf("%ld\n", epochtime );
   }



}

Last edited by crabboy; 06-01-2007 at 09:53 AM.
 
Old 06-02-2007, 03:46 PM   #6
gbratig
LQ Newbie
 
Registered: Jun 2006
Posts: 14

Original Poster
Rep: Reputation: 0
That's perfect!!! thank you very much, but really, thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get date from unix timestamp ruj.sabya Linux - General 9 03-22-2007 05:59 PM
thunderbird puts time instead of date under 'date' header wabbalee Linux - Software 4 11-26-2006 04:58 AM
Cannot set time/date to other time zone than UTC (Kubuntu) jamangold Ubuntu 1 12-23-2005 05:42 PM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
convert date time format given in string suchi_s Programming 6 01-10-2005 04:06 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 01:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration