April 5, 2011

How to convert Unix timestamps

It's been a long *time* since my last post, hence I thought I'd do a post that involves time. I often run into the situation where I have a Unix timestamp and I need to determine the date. You can use the following to do this.

mike@shiner $ date -d @1252278000
Sun Sep  6 19:00:00 EDT 2009

The following shows how to get the Unix timestamp for a particular moment in time.

mike@shiner $ date -d "2009-09-06 19:00:00" "+%s"

1 comment:

  1. Nice. Many of my scripts need the current unix timestamp:

    now=`date +%s`