Tag Archives: time

Get DateTime in YYYY-mm-dd HH:MM:SS format using Perl

For many years I’ve been using the long process of obtaining everything from localtime(), adding 1900 to the year etc. etc. but I’ve just come across the method below, which uses strftime from the POSIX module. use POSIX;   my $DateTime = strftime "%F %T", localtime $^T; This gives you: 2006-10-02 02:06:07 Now that’s a [...]

Set date and time in Linux

Use the following syntax to set new data and time: # date set="STRING" For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user: # date -s "2 OCT 2006 18:00:00" OR # date set="2 OCT 2006 18:00:00" You can also simplify format using following syntax: # date +%Y%m%d [...]