Compare Unix date and time.
To get Unix time, the command is:
current time:
now=`date +"%T"`
we will get a time like "20:55:01"
now=`date +"%H%M%S"`
we will get a time like "205501"
If we want to compare times, we can not compare the times in the format "%H:%M:%S", we can only compare them in the format "%H%M%S". Otherwise we will get an error Illegal number: 20:59:22
To get Unix date, the command is:
date1=`date +"%m/%d/%Y %H:%M:%S"`
We will get a date in like "5/8/2018 20:55:01"
If we want to get timestamp, we will use:
date2=`date +"%s"`
we will get a unix timestamp.
we can compare dates by its unix timestamp. it seems we can not compare two dates like "5/8/2018 20:55:01". Otherwise we will get an error: Illegal number: 05/08/2018 20:59:22.
I wrote about the solutions to some problems I found from programming and data analytics. They may help you on your work. Thank you.
ezoic
Subscribe to:
Post Comments (Atom)
looking for a man
I am a mid aged woman. I was born in 1980. I do not have any kid. no complicated dating before . I am looking for a man here for marriage...
-
I tried to commit script to bitbucket using sourcetree. I first cloned from bitbucket using SSH, and I got an error, "authentication ...
-
https://github.com/boto/boto3/issues/134 import boto3 import botocore client = boto3.client('s3') result = client.list_obje...
-
Previously, I wanted to install "script" on Atom to run PHP. And there was some problem, like the firewall. So I tried atom-runner...
No comments:
Post a Comment