Review your favorite Linux distribution.
Go Back > Blogs
User Name



Date and time functions

Posted 12-09-2013 at 12:34 PM by druuna
Updated 01-31-2014 at 04:25 AM by druuna (Small changes to layout)
Tags date, seconds, time

A handful of date and time related functions that might come in handy.
  • Convert a date or time string to seconds from epoch
PHP Code:
# ------------------------------------------------------------------ #
# Function : dateToSecs
# Syntax   : dateToSecs "[date]"
# Convert a date or time string to seconds from epoch.
# ------------------------------------------------------------------ #
function dateToSecs() {
  [[ $
# -eq 0 ]] && date --utc 
LQ Veteran
Posted in General
Views 590 Comments 0 druuna is offline

Automatically set file date from EXIF data

Posted 12-27-2010 at 03:54 PM by jere21
Updated 12-27-2010 at 03:59 PM by jere21

You can set the creation date of a picture or video as its access and modification time: If the creation date was saved in the exif data of some media, you can extract it with "exiftool -ee -CreateDate" and then "touch" the file with that time.

To do this automatically save the following script e.g. as /usr/local/bin/exiftool_set_create_date
# exiftool_set_create_date: set the file date from exif "Creation Date".
echo -n "$@:
LQ Newbie
Posted in Uncategorized
Views 2316 Comments 0 jere21 is offline

Getting a timestamp string in a Windows cmd.exe variable

Posted 12-12-2010 at 01:31 PM by catkin

This technique was developed to generate a timestamp string for rsync's --backup-dir option but it could be generally useful.

The first issue is that the value of %DATE% depends on Windows' regional settings so is not portable. The same goes for the output format of cmd.exe's builtin command date. (one example of many discussions: this StackOverflow thread). There is no way to program around this in a .BAT or .CMD script. The chosen solution was to UnxUtils' date.exe which is a...
LQ 5k Club
Posted in Uncategorized
Views 4427 Comments 0 catkin is offline


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration