(probably stupidly simple) if [ $var1 = $var2 ] problem...

OK, while I'm not new to the Mac or some of the the inner workings of Mac OS X I am quite new to scripting. And while I have "Learning the Bash Shell" by those lovely people at O'Reilly (Cameron Newham et. al.) I'm missing something, I just know I am.

Here's the problem:

At the beginning of my script I declare 2 variables:

#Uncomment the next line for log lines to be timestamped with the server's local time (BST, GMT, etc.)
timestamp=$(date)

#Uncomment the next line for log lines to be timestamped with UTC (Universal Coordinated Time)
#timestamp=$(date -u)

Then, later I want to log which type of timestamp is being used, so I tried every variation I could think of on:

if [ $timestamp=date ]
	then
		echo -e $timestamp "\tLogging using Server's Local Time" >> /path/to/logfile.log
	else
		if [ $timestamp=date -u ]
			then
				echo -e $timestamp "\tLogging using UTC" >> /path/to/logfile.log
			else
				echo -e $timestamp "\tI don't know what timestamp I'm logging with, but I'll carry on" >> /path/to/logfile.log
		fi
fi

My problem occurs at the [ $timestamp=date ] and [ $timestamp=date -u ] bits. It fails numerous ways and the best I've got is where it logs both "Logging using Server's Local Time" AND "Logging using UTC".

I've tried various combinations of:

[ $timestamp=date ] #btw, single brackets invariably end up in a 'too many arguments' complaint from the shell
[ $timestamp='date' ]
[[ $timestamp=$(date) ]]

etc...

I also tried this

fndate()
{
date
return $fndatevar
}

(and one for date -u)

and then using them like:

if [ $timestamp=$fndatevar ]

etc.

Still no joy

... I could go on. But at 03:00 this morning I decided to go to bed and ask. So here I am, asking.

Is it clear what I'm trying to do? Test which version of $timestamp the script is using an log the fact (even though it'll be obvious from the timestamps themselves which version is being used. It's more an exercise in what's possible and to learn how to do it than to do any rocket science).

Many thanks to those about to help me.

if [ "$timestamp" = "$(date)" ]

if [ "$timestamp" = "$(date -u)" ]

Use quotes + date has to execute as a child process in order top return a value.

I'm sure I tried those variations last night. I'll have another go as to be honest my brain was getting a bit wooly around the edges by the end of it all and I might just be randomly lying!

Anyway, thank you. I appreciate the swiftness of response!