a small amount of code, but not so much as to alter other commands

without changing php.ini or another permanent but more difficult solution
please tell me how to change

date('l jS \of F Y h:i:s A')

add more code to change to eastern standard time zone

date_default_timezone_set('America/New_York';)
works but
not my code I just want to create one command to see if code is continuously working

and
date_default_timezone_set('America/New_York';)
would alter the log file which I didnt create
LVL 1
rgb192Asked:
Who is Participating?
 
Ray PaseurCommented:
Yes, that's the idea.  I tested it quite a few times and it seemed to work correctly - never lost a second!  It could, in theory, lose a second, but it did not happen to me yet.
0
 
Ray PaseurCommented:
Not 100% sure I understand the question, but this might be a strategy.  You can retrieve the current settings with date_default_timezone_get().  Save this value in a variable.  Then set the Eastern time zone, recover the formatted date() and store the date string in a variable.  Then set the original timezone back.
http://iconoun.com/demo/temp_rgb192.php
<?php // demo/temp_rgb192.php

/**
 * http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28663001.html
 */
error_reporting(E_ALL);

function other_date($z = 'America/New_York', $p = 'l jS \of F Y h:i:s A')
{
    $d = date_default_timezone_get();
    date_default_timezone_set($z);
    $r = date($p);
    date_default_timezone_set($d);
    return $r;
}

echo '<pre>';
echo PHP_EOL . "LOCAL: " . date('c');
echo PHP_EOL . other_date();
echo PHP_EOL . "LOCAL: " . date('c');

Open in new window

0
 
rgb192Author Commented:
so this function sets the local time and then sets it back to whatever time that code had previously
0
 
rgb192Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.