changing date to resemble "messages file" date

the following was taken from a perl script:

my $date = strftime "%B %d %H:%M:%S", localtime;

how can i modify it so this date outputs the date in the form of the date of the messages file. for example:

Sep 20 11:48:44

As it is right now, the perl script outputs the date like this:

September 20 11:50:45

also, in the messages file, if the date of the current day is a single digit day (for example the 6th of september), it outputs the date like this:

Sep  6 11:48:44

notice there are two spaces between the month and the date.

how do i make the perl script do both of these? and by both of these i mean the (shortening of the month name, and the insertion of two spaces between the month and day IF the day of the month is single digit).

Change "%B %d" to "%b %e" in your script.

1 Like