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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I guess localtime is not what I want. I want to explicitly ask for EST or, more correctly, EDT.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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