/home/wpollock1/public_html/ShScript/timestamp.sh

#! /bin/sh -
#
# POSIX script to display the current "Unix time",
# that is the number of seconds since midnight 1/1/1970.
# Note shell arithmetic can't be used as the values overflow.
#
# $Id: timestamp.sh,v 1.1 2009/10/15 15:57:31 wpollock Exp $
# Written 10/2009 by Wayne Pollock, Tampa Florida USA

set -- $(date -u '+%S %M %H %j %Y')
SEC="$1"
MIN="$2"
HR="$3"
DAY=$(( $4 - 1 ))  # Day of year in range [0..365]
YR=$(( $5 - 1900 ))

TIME=$(printf '%s\n' "$SEC + $MIN*60 + $HR*3600 + $DAY*86400 + \
  ($YR-70)*31536000 + ( ($YR-69)/4)*86400 - \
  ( ($YR-1)/100)*86400 + ( ($YR+299)/400)*86400" |bc)

printf '%s\n' "$TIME"

# Geoff Clare <netnews@gclare.org.uk> posted this POSIX solution
# on 10/13/2009 on comp.unix.shell "Re: Compute seconds since
# 1st Jan 1970.":
#
# FILE=/tmp/timestamp-$$  # mktemp is not POSIX but see mktemp.sh
# trap 'rm $FILE; trap - 0; exit' 0 1 2 3 15
# touch $FILE
# printf '%d\n' 0"$(pax -wxcpio $FILE |
#    dd bs=1 skip=48 count=11 2>/dev/null)"