Convert epoch time to Julian date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert epoch time to Julian date
# 1  
Old 11-22-2013
Convert epoch time to Julian date

Need assistance in converting an epoch time to Julian date


To get epoch

Code:
perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"'

# 2  
Old 11-22-2013
Are the numbers in the timelocal function call from a Gregorian date?

Does that mean to want to take a Gregorian date to an Epoch, and now you want to convert it a Julian date?

(it seems like an unusual request, so I just wanted to make sure Smilie)
# 3  
Old 11-22-2013
Yes from Gregarian calender to Julian date

---------- Post updated at 04:39 PM ---------- Previous update was at 01:52 PM ----------

Found a way to get the julian date

Code:
use POSIX qw(strftime);
my $time = timegm($sec,$min,$hour,$day,$mon,$year);
print strftime "%j", gmtime($time);

This User Gave Thanks to ajayram_arya For This Post:
# 4  
Old 11-23-2013
You may try

Code:
#!/bin/bash

# Usage : Julian STANDARD DAY MON YEAR HOUR MIN SEC
function Julian(){

                   std=$1    
                   Day=$2 ; Mon=$3 ; Year=$4
                   Hour=$5; Min=$6 ; Sec=$7

case "$std" in
    CNES )
                 # Cnes Julian days start at January 1st, 1950    
                 start="Jan 1 1950 12:00:00 AM";;
    NASA ) 
                 # Nasa Julian days are number of days since January 1st, 1958 
                 start="Jan 1 1958 12:00:00 AM";;
        *) 
                 echo "Invalid option" && exit;;
esac

               # Julian Day
                 jd=$(( ( $(date -d "$Year$Mon$Day" +%s) - $(date -d "$start" +%s) ) /(24 * 60 * 60 ) ))
                 ttime=$(echo $Hour $Min $Sec | awk '{print $2/24 +$3/(60*24)+ $4/(60*60*24)}')

               # Realtime Julian Day
                 rjul=$(echo $jd $ttime | awk '{printf "%5.3f\n", $1+$2}')

                  }

printf "\nCalendar Date  : 31-12-2013 10:10:10\n\n"

# CNES Standard
Julian CNES 31 12 2013 10 10 10
printf "CNES Standard\n\tJulian Day : $jd\n\tRealtime Julian Day : $rjul\n"

# NASA Standard
Julian NASA 31 12 2013 10 10 10
printf "NASA Standard\n\tJulian Day : $jd\n\tRealtime Julian Day : $rjul\n\n"

Resulting

Code:
$ ./Julian

Calendar Date  : 31-12-2013 10:10:10

CNES Standard
    Julian Day : 23375
    Realtime Julian Day : 23375.424
NASA Standard
    Julian Day : 20453
    Realtime Julian Day : 20453.424

following link may be useful to you
http://www.aviso.oceanobs.com/en/dat...lian-days.html

Last edited by Akshay Hegde; 11-23-2013 at 04:10 AM..
This User Gave Thanks to Akshay Hegde For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Second Column Date Into EPOCH Time And Print Complete Row

Hello Team, I am stuck in getting the required output in the following case. Please help. My input file is aa|08/01/2016 bb|08/15/2016 I wish to convert the file into aa|epoch time bb|epoch time I am using following code: (3 Replies)
Discussion started by: angshuman
3 Replies

2. Shell Programming and Scripting

Convert to epoch time

how can i modify the following command to instead provide the epoch time of the interfaces file? perl -le 'print scalar localtime ((stat "/home/skysmart/interfaces"))' Tue Feb 19 03:44:52 2013 i'm hoping to get the equivalent of this command: stat --format=%Y /home/skysmart/interfaces ... (2 Replies)
Discussion started by: SkySmart
2 Replies

3. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

4. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

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

6. Shell Programming and Scripting

Convert epoch to human readable date & time format

Hello I have log file from solaris system which has date field converted by Java application using System.currentTimeMillis() function, example is 1280943608380 which equivalent to GMT: Wed, 04 Aug 2010 17:40:08 GMT. Now I need a function in shell script which will convert 1280943608380... (3 Replies)
Discussion started by: Yaminib
3 Replies

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

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

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

10. Shell Programming and Scripting

convert Julian date to calender date

Hi, I have script in unix which creates a julian date like 126 or 127 I want convert this julian date into calender date ex : input 127 output 07/may/2007 or 07/05/2007 or 07/05/07 rgds srikanth (6 Replies)
Discussion started by: srikanthus2002
6 Replies
Login or Register to Ask a Question