Compare non-standard time format to now() in linux

Chiuso

Descrizione

I run debian on a raspberry pi and want to see if a given timestamp is older than X hours. This would be trivial if the timestamp was in a standard format, but unfortunately that is not the case.

The timestamp has the following format:

November 5, 2016 at 12:50AM

or

November 14, 2016 at 04:35PM

I'm looking for a tool that can take in a timestamp in a given input-format, and convert to another time format. I can use any tools as long as they are available on debian/raspberry pi.

What I'm looking for is something like this:

#!/bin/bash

timeout="1440" # 24 hours = 1440 minutes

now=$(date +"%Y%m%d%H%M") # = 201611271814

timestamp_raw="November 5, 2016 at 12:50AM"

timestamp=$(convert "$timestamp_raw" --inputformat +"%B %e, %Y at %I:%M%p" --outputformat +"%Y%m%d%H%M") # this command is fictitious but should produce something like 201611050050

comparedate=$(expr $now - $timeout) # = now() - 24 hours

if [ $timestamp -ge $comparedate ];

then

echo 'yes';

fi

Can you point me in the right direction?

Competenze: Linux

Mostra altro: standard non disclosure statement, standard non disclosure form, standard non disclosure agreement, format time stamp transcription, highcharts csv format time series example, codeigniter date linux time, adf xml format industry standard, online linux time calculator, metastock format real time data australia, macro format time textbox, linux time trial, linux time password radius, linux time password freeradius, convert movie android format linux, linux time password, format number time bash, linux time expiration login script free, linux time zone romania, perl script convert xml document csv format linux, format time excel form, excel vba csv number format time, convert swf dvd movie format linux open source, php linux time, asp format linux, apa format compare contrast

ID Progetto: #12207123

Assegnato a:

$15 USD in 0 giorni
(31 valutazioni)
4.9