Question
php input date/time as timestamp with timezone
This is a nightmare!!!!
I have numerous databases, all of which use timestamp format date/times, which are easy to echo according to user timezone preferences using putenv ("TZ=".$_SESSION['MM_UTZ']); and echo date($_SESSION['MM_UTF'], ($whatever));
The only problem is, I have only used these for stamping "date created" or "date edited" values using Time()
What I am trying to achieve is:
User 1 in UK enters date and time, using a javascript datetime picker (which normally enters data into field in Y-m-d H:i:s) and the php inserts this in timestamp format according to timezone.
User 2 in US looks at date and time and this is echo'd according to his timezone.
Sounds simple...
I have managed to get so far with the new DateTime object which incorporates the user timezone preference ($utz)
$ndttime= new DateTime($timefield, new DateTimeZone($utz));
I can then echo this effectively using
echo $ndttime->format('$utf'); ($utf being user timeformat preference)
My stupid problem is trying to get the $ndtime into the database!!!!
I know this sounds ridiculous but I use the DW insert wizard which only uses values from a form and if I echo $ndtime into a hidden field, it doesn't process this value in time.
I attach the current insert script.
Is this simple?
Heeeeelp.
I have numerous databases, all of which use timestamp format date/times, which are easy to echo according to user timezone preferences using putenv ("TZ=".$_SESSION['MM_UTZ']); and echo date($_SESSION['MM_UTF'], ($whatever));
The only problem is, I have only used these for stamping "date created" or "date edited" values using Time()
What I am trying to achieve is:
User 1 in UK enters date and time, using a javascript datetime picker (which normally enters data into field in Y-m-d H:i:s) and the php inserts this in timestamp format according to timezone.
User 2 in US looks at date and time and this is echo'd according to his timezone.
Sounds simple...
I have managed to get so far with the new DateTime object which incorporates the user timezone preference ($utz)
$ndttime= new DateTime($timefield, new DateTimeZone($utz));
I can then echo this effectively using
echo $ndttime->format('$utf'); ($utf being user timeformat preference)
My stupid problem is trying to get the $ndtime into the database!!!!
I know this sounds ridiculous but I use the DW insert wizard which only uses values from a form and if I echo $ndtime into a hidden field, it doesn't process this value in time.
I attach the current insert script.
Is this simple?
Heeeeelp.
