Strange behaviour of the strftime() function from gawk (3.1.5):
$ awk 'BEGIN{print strftime("%T", 3600)}'
> 02:00:00
$ awk 'BEGIN{print strftime("%T", 0)}'
> 01:00:00
Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not.
From... (2 Replies)
I have two files and would like a report of where they match.
Example of file1:
1 1 1
2 2 2
13 14 15
4 4 4
15 16 17
100 102 1004
56 57 890
Example of file2:
2 2 2
16 10 11
45 22 35
13 14 15
1001 1002 3456
100 102 1004 (1 Reply)
As Brendan O'Conner writes in this blog, mawk is near 8 times faster than gawk, so I am going to give mawk a go, but I got errors when trying to print the length of an array in mawk using length() function, is it not supported in mawk? or there's another way to get the length of an array in mawk?
... (3 Replies)
HI,
i wish to convert a millsec value to a readable string format.
the one option is to use strftime.
However this is a bit costly (1-5 micros).
is there a a faster way to do so with just string manipulation
(Note i have the date object which has the time details but wish o avoid strftime) (2 Replies)
Hi,
I have a line which has n number of words with separated by space.
I wanted to make each word as a separate line.
for example,
i have a file that has line like
i am a good boy
i want the output like,
i
am
a
good (8 Replies)
Hello, I am looking to make a text based game, that runs in the command window, or a window similar. I will only need to use 1 window.
I read somewhere that there is libraries for this kind of thing? But I can't remember the name of them.. Can anyone point me in a direction?
I will be... (2 Replies)
Hi,
I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond
Starttime 2013-04-03 08:54:19,989
End time 2013-04-03 08:54:39,389 (9 Replies)
So, I do some file processing that generates very large numbers, such as total amount GETted from a busy web cluster in a month, etc. Mawk is awesome-- fast and easy. It's awk! But, there's a fatal flaw that I'd like to overcome. Apparently, %d maxes out at 2147483647. Here's sample output,... (11 Replies)
I'm trying to use AWK to filter on some dates in a field by converting them to Unix Time.
mktime(strftime(format,"6-FEB-2013 08:50:03.841")What is the proper format for my date strings as they appear in my database?
My first thought is %d-%b-%Y %H:%M:%Sbut I see the following issues:
%d is... (3 Replies)
Discussion started by: Michael Stora
3 Replies
LEARN ABOUT PHP
rand
RAND(3) 1 RAND(3)rand - Generate a random integerSYNOPSIS
int rand (void )
DESCRIPTION
int rand (int $min, int $max)
If called without the optional $min, $max arguments rand(3) returns a pseudo-random integer between 0 and getrandmax(3). If you want a
random number between 5 and 15 (inclusive), for example, use rand(5, 15).
Caution
This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a
cryptographically secure value, consider using random_int(3), random_bytes(3), or openssl_random_pseudo_bytes(3) instead.
Note
On some platforms (such as Windows), getrandmax(3) is only 32767. If you require a range larger than 32767, specifying $min and
$max will allow you to create a range larger than this, or consider using mt_rand(3) instead.
PARAMETERS
o $min
- The lowest value to return (default: 0)
o $max
- The highest value to return (default: getrandmax(3))
RETURN VALUES
A pseudo random value between $min (or 0) and $max (or getrandmax(3), inclusive).
EXAMPLES
Example #1
rand(3) example
<?php
echo rand() . "
";
echo rand() . "
";
echo rand(5, 15);
?>
The above example will output something similar to:
7771
22264
11
SEE ALSO srand(3), getrandmax(3), mt_rand(3), random_int(3), random_bytes(3), openssl_random_pseudo_bytes(3).
PHP Documentation Group RAND(3)