How to find day of week in php in a specific timezone

I am confused while using php to handle date/time.

What I am trying to do is this: When a user visits my page I am asking his timezone and then displaying the 'day of week' in his timezone.

I don't want to use the browser's day. I want to do this calculation in php.

This is how I am trying to achieve it:

  1. The timezone entered by user
  2. Unix time stamp calculated by php time() function.

But I dont know how to proceed... How would i get the 'day of week' in this timezone.


Solution 1:

$dw = date( "w", $timestamp);

Where $dw will be 0 (for Sunday) through 6 (for Saturday) as you can see here: http://www.php.net/manual/en/function.date.php

Solution 2:

My solution is this:

$tempDate = '2012-07-10';
echo date('l', strtotime( $tempDate));

Output is: Tuesday

$tempDate = '2012-07-10';
echo date('D', strtotime( $tempDate));

Output is: Tue