Problem with time

(let me re-edit my question)

This works

#!/bin/sh
awk 'BEGIN {print mktime("2005 07 01 34 30")}

This doesnt

#!/bin/sh
TIME="2005 07 01 34 30"
awk 'BEGIN {print mktime($TIME)}

what could be the problem? arent they the same thing?

Neither will run as you present it. Adding a closing quote and a file, I tried this on SunOS:
awk 'BEGIN {print mkzzzime("2005 07 01 34 30")}' < /dev/null
and I got:
2005 07 01 34 30

There is no such thing as mkzzzime in awk, but there is no mktime either. awk on SunOS is ignoring a bogus function. On HP-UX, I get:
awk: Function mktime is not defined.
The source line number is 1.

Your sh knows about a variable called TIME, but your awk does not. Even if it did, that's not how you use a variable in awk. You might try something like:
p=987
awk -v p=$p 'BEGIN {print p}' < /dev/null

See the faq section, specificly,
Passing variables/arguments/parameters to commands.

hmmz strange, im using SunOS as well and mktime is defined,

the first code returns "1102738530" (which is correct)

where the second code returns "-1"

strange indeed. :frowning:

what awk are you using on SunOS: awk, nawk, /usr/xpg4/bin/awk, gawk?

''mktime' is only supported by gawk - check your ${PATH} and make sure your 'awk' is not linked to gawk.

oh yes, it is linked to gawk i just checked ...
but the result still remains the same.

#!/bin/sh
TIME="2005 07 01 34 30 10"
gawk -v t="${TIME}" 'BEGIN {print mktime(t)}'

ahhh BINGO!