O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The strftime (format, timestamp) function

The strftime() function is used to create a human-readable time string based on the current time. It is quite similar to the shell command date. It returns the current date in seconds by default; however, we can use this to create a string based on the time. The first argument to the strftime function takes a string to specify the format of the output date. The second argument is a timestamp in the same format as the value returned by the systime function. If the second argument is not specified, then GAWK uses the current time of day as the timestamp. The following example shows how the strftime() function works:

$ vi strftime.awkBEGIN    {    format = "Todays date is : %d-%m-%Y %H:%M:%S"     print strftime( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required