Find Jobs
Hire Freelancers

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

$10-30 USD

Completed
Posted over 7 years ago

$10-30 USD

Paid on delivery
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?
Project ID: 12207123

About the project

1 proposal
Remote project
Active 7 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
$15 USD in 0 day
4.9 (31 reviews)
4.9
4.9

About the client

Flag of NORWAY
Norway
5.0
73
Payment method verified
Member since Jul 10, 2003

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.