Search This Blog

Shell Script: conversion between seconds and dates

  • The following command gets current date/time in seconds:
    seconds=$(date +%s)
    
  • The following command formats seconds to specified date format:
    date -d @${seconds} +"%Y%m%d %H%:M:%S"
    

No comments:

Post a Comment