Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Getting the current time from a website and parsing date Post 303008866 by apmcd47 on Thursday 7th of December 2017 04:35:42 AM
Old 12-07-2017
Apart from why?, and assuming GNU Date is in your toolkit and assuming a modern bash, ksh or zsh:

Code:
seconds=$((  $(date -u +"(%H*60 + %M)*60 + %S" --date="$(curl -s --head web-url | sed -n 's/^Date: //p')") ))

It may take a little longer than a pure awk route and relies on date understanding the format.

Or how about
Code:
seconds=$(($(curl -s --head web-url | \
             sed -n '/^Date: / s/^.*\([0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\).*$/(\1*60 + \2)*60 + \3/p') ))

(pure sed but still relies on $(()) operators in shell)

Andrew
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

param as current date+time

Hi All, I need to pass param on aix "errpt -a -s MMDDHHMMYY -e MMDDHHMMYY". How do I read the date+time on the system and pass it as parameter? I need also the -s as previous day and the -e as current day. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies

2. Shell Programming and Scripting

Get date and time for past 1 hour from current date

Hi, I need to get the date and time for past 1 hour from the current date. Anyone know how to do so? Thanks (5 Replies)
Discussion started by: spch2o
5 Replies

3. Shell Programming and Scripting

Prefix the current date and time to the output of ps

Hi, I need to write a script, that will take the current date, time, and the output from # ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm and spit it to a file, so it'll look like this... PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND 1 1 TS... (2 Replies)
Discussion started by: Bloke
2 Replies

4. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

5. Shell Programming and Scripting

How far is given date from current time?

give a date and time: Jun 12 21:05:16 06-12-2012 21:05:16 2012/06/12 21:05:16 How can i subtract these dates and times from the current date and time and get back the difference in seconds? a one liner like: echo "Jun 12 21:05:16" | some perl/awk programming 90900s (2 Replies)
Discussion started by: SkySmart
2 Replies

6. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

7. Shell Programming and Scripting

[Solved] How to tar data along with current system date and time.?

Hi all, Following is my small script:- #!/bin/ksh for i in `cat /users/jack/mainfile-dr.txt` do sudo cp -r $i /users/jack/DR01/. done cd /users/jack/DR01/ sudo tar cvf system1-DR.tar * scp system1-DR.tar backupserver:/DRFiles/system1 sudo rm -rf system1-DR.tar In this script I... (10 Replies)
Discussion started by: manalisharmabe
10 Replies

8. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

9. Shell Programming and Scripting

Add current date and time

i have file 1.txt asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney i want to add today's date and time in the end of each row expected output asdas|csada|13|03|10|04|23|A1|canberra|130430|1358 sdasd|sfdsf|13|04|26|23|28|A1|sydney|130430|1358 todays date... (10 Replies)
Discussion started by: radius
10 Replies

10. Shell Programming and Scripting

Need to substract date with current date and time

I have below file which contain the date in column 3,4,5 12345 open 10/10/13 10:08 PM 3 application is in java 67899 open 12/10/13 2:31 AM 2 apps can be reach 23456 open 11/9/13 2:31 AM 4 java is OK 65432 open 12/10/13 10:07 PM 9 we are... (1 Reply)
Discussion started by: vijay_rajni
1 Replies
LIBGPHOTO2_PORT(3)					  The gPhoto2 Reference (the man					LIBGPHOTO2_PORT(3)

NAME
libgphoto2_port - cross-platform port access library SYNOPSIS
#include <gphoto2/gphoto2_port.h> DESCRIPTION
The libgphoto2_port library was written to provide libgphoto2(3) with a generic way of accessing ports. In this function, libgphoto2_port is the successor of the libgpio library. Currently, libgphoto2_port supports serial (RS-232) and USB connections, the latter requiring libusb to be installed. The autogenerated API docs will be added here in the future. ENVIRONMENT VARIABLES
IOLIBS If set, defines the directory where the libgphoto2_port library looks for its I/O drivers (iolibs). You only need to set this on OS/2 systems and broken/test installations. LD_DEBUG Set this to all to receive lots of debug information regarding library loading on ld based systems. USB_DEBUG If set, defines the numeric debug level with which the libusb library will print messages. In order to get some debug output, set it to 1. SEE ALSO
libgphoto2(3), The gPhoto2 Manual, [1]gphoto website, automatically generated API docs, [2]libusb website AUTHOR
The gPhoto2 Team. Hans Ulrich Niedermann <gp@n-dimensional.de>. (man page) REFERENCES
1. gphoto website http://www.gphoto.org/ 2. libusb website http://libusb.sourceforge.net/ 08/16/2006 LIBGPHOTO2_PORT(3)
All times are GMT -4. The time now is 07:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy