curiouswebster
asked on
PHP: getting local time
In this Prepared Statement, I have trouble getting localtime.
Previously, I saw a PHP function that let me insert 'localtime'
$smt->bindValue(':create_date', date("Y-m-d h:i:s"), SQLITE3_TEXT);
Suggestions?
Thanks
Previously, I saw a PHP function that let me insert 'localtime'
$smt->bindValue(':create_date', date("Y-m-d h:i:s"), SQLITE3_TEXT);
Suggestions?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I guess localtime is not what I want. I want to explicitly ask for EST or, more correctly, EDT.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does this call:
date_default_timezone_set("America/New_York");
also set the page, when I use DateTime objects?
date_default_timezone_set("America/New_York");
also set the page, when I use DateTime objects?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This code crashes my page:
$date = new DateTime(null, new DateTimeZone('America/New_York'));
echo $date->format('Y-m-d H:i:s') . "\n"
$date = new DateTime('2000-01-01'); // WORKS
echo $date->format('Y-m-d H:i:sP') . "\n";
$date = new DateTime(null, new DateTimeZone('America/New_York')); // FAILS
echo $date->format('Y-m-d H:i:s') . "\n"
What am I missing?
$date = new DateTime(null, new DateTimeZone('America/New_York'));
echo $date->format('Y-m-d H:i:s') . "\n"
$date = new DateTime('2000-01-01'); // WORKS
echo $date->format('Y-m-d H:i:sP') . "\n";
$date = new DateTime(null, new DateTimeZone('America/New_York')); // FAILS
echo $date->format('Y-m-d H:i:s') . "\n"
What am I missing?
ASKER
You know what, Scott? After reading your post. I probably should use UTC for all data INSERT and UPDATE calls, and use local time for the UI. So, I presume I would set the config.php to be UTC. Then, when displaying the current time (if I ever needed to) I would display localtime.
Make sense?
Make sense?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So,I need the attribute for localtime.
Here is the Prepared Statement, which seems to be adding new records without errors:
Open in new window