Timestamp in batch files on international systems

Timestamps in batch scripts are rather useful when it comes to data storage in a chronological order, for example in the instance of backups, where it is important to store the data on a daily basis and being able to discern the particular day when used for restoration.

Creating a Timestamp

An easy two-liner in the batch script should guarantee that the correct timestamp is being stored in a variable:

However, it is necessary to avoid certain obstacles, otherwise unusable results might be forwarded.
The output should generally look as follows:

The value of this STAMP variable is useless, since it returns an unusable date avalue.

 

Possible Solutions

There are multiple possibilities how to solve this problem. It is possible, for example, to adjust the script to each system - which can be particularly tedious when the individual systems have different regional configurations.

It is, however, also possible to change the regional settings in such a manner that they are returned as follows:

Conclusion

The easiest and most organized way to generate a timestamp from an international system or from a Zope installation running Python Standalone is:

Generate a new file with the end string *py, open it in a text editor, paste the following code into it, and save it.

Generate a new batch script, paste the following code into it, adjust the respective paths - voila!

Regardless of which regional settings the system is running under, it will always return the correct timestamp.