Engineerix Software Services
Deutsch  English  

Engineer.iX DateTimeF

 

Program: Engineer.iX DateTimeF
Version:

1.0

 

Last Changes (Change Log)

 

+ Base Program for generating formatted date and/or time in Windows shell (Command line)

 

Autor: Jack (tR)
Copyright and Licence:

© 2011, Engineer.iX Software Services
Freeware Licence (free use, no warranty, commercial distribution requires explicit permission)

 

Please mind that you use this program at your own risk. We don't take any responsability for damages that result directly or indirectly from the use of this software.

 

Note: This program is using FAMFAMFAM Silk Icons v1.3

System requirements: .NET 2.0
Homepage: http://www.engineerix.de/.net/datetimef
Download:

Latest Version [PGP] [MD5] [SHA1]

 

This program is a tiny command line helper for generating a user formatted time stamp of the current date/time in order to use the result as a command line argument for running batch files inside the Windows Shell. It was originally developed to run a backup batch with a command line parameter that consists of the day of the week and the current hour (e.g. backup.bat bak\Sun\07).

The following screen shows how to apply the application:

DateTimeF main form 

As you can see the application has to be called with only one parameter - a string that is quoted in " and contains the time formatting instructions. The common syntax for the command line call is:

datetimef.exe "%Y %m %d %H %i %s"

The format codes are following the style of the PHP date() function (http://php.net/manual/de/function.date.php) the only difference is that the codes for datetimef all have to start with an "%". So Where in PHP you normally would write "Y-m-d H:i:s" to get a date like "2001-05-03 15:30:12" here for DateTimeF you have to write "%Y-%m-%d %H:%i:%s" ..

 

If you have a special wish or a fancy idea how to expand this program in a sensible way, do not hesitate and best contact us directly.

 

 

Typical Use Cases


Case 1 - Generating current time stamp in user defined format in order to use it as a command line parameter for batch files in WIndows Shell

In our specific case we had a batch file that was periodically triggered by the windows task scheduler in order to run a file backup every full hour. The files copied by the backup had to be saved in a specific backup directory that is named like the current weekday and the current hour (e.g. \backup\Mo\17).

As there (in Windows) is no way to give the date and time from the task scheduler to the called batch file we decided to give it a little help... (after wasting lot of time trying it by cropping the date command using the poor windows shell batch commands)..

At the end - thanks DateTimeF - we had a working batch file that looked like following.

daily.bat:

@echo off
for /f %%i in ('DateTimeF.exe "%%D\%%H"') Do @set BackDir=%%i

robo_backup %BackDir%

For all who are not a fan of Windows Shell batch programming, here a short explanation:

The first line switches of the echoing of the following commands, the second line copies the result of the call of DateTimeF %D\%H into the variable %BackDir% and finally in the third line this variable gets used as a Parameter for calling another batch file (where it is accessible under the name %1). The robo_backup.bat uses this variable as an argument to call robocopy in order to backup files to the directory. (robocopy is a tool by Microsoft for Copying or Mirroring file trees).

DateTimeF originalle was used together with Dedundancio which we used after the robocopy to remove redundancies from the copied files in order to save disk space.

 

*** You could also reach all that using Windows Power Shell but this requieres a installed Windows Power Shell (you can download at Microsoft) and furthermore you have to config the Powershell for giving priviledges for your batch file.

 

 


Last Update on: 25 Jul 2011

Copyright © 2004-2011, Engineer.iX Software Services. All rights reserved. Legal Info, SiteMap