JaredRitchey Posted May 25, 2011 Share Posted May 25, 2011 I have a batch script that reads from a timestamp.txt file to determine the last time it ran and I need to modify that by two hours. What happens is the script will run to look for changes in the county records and their server time is two hours different from mine. $fr=fopen("xml/timestamp.txt",'r'); $mydate=fread($fr, 50); if ($incremental_updates == 1){ $default_template_file="xml/incremental_template.xml"; $default_config_name="xml/incremental.xml"; $contest=file_get_contents($default_template_file); $contest=str_replace("{DATE_TAG}", $mydate, $contest); $f=fopen($default_config_name,'w+'); fwrite($f, $contest); fclose($f); fclose($fr); $fw=fopen("xml/timestamp.txt",'w'); fwrite($fw, substr(date('c'), 0, 19)); fclose($fw); }else{ $default_config_name = "xml/full_update.xml"; } I tried making a time stamp update look like $cur_timestamp=date("Y-m-d H:i:s", time() +14400); which is correct but it doesn't write to the text file properly. Using the above fwrite($fw, substr(date('c'), 0, 19)); I get the correct results in the timestamp.txt file for my server time. I need it to be +14400 2011-05-25T08:27:51 would essentially become 2011-05-25T10:27:51 when it writes to the timestamp.txt I hope that makes sense. J Link to comment https://forums.phpfreaks.com/topic/237432-datetime-help/ Share on other sites More sharing options...
JaredRitchey Posted May 25, 2011 Author Share Posted May 25, 2011 I realize I may have made that more complex than it needs to be. Here it is in simpler terms. If I do this; echo substr(date('c'), 0, 19); I can get back this; 2011-05-25T08:45:27 I want it to return this; 2011-05-25T10:45:27 Which simply adds two hours. Link to comment https://forums.phpfreaks.com/topic/237432-datetime-help/#findComment-1220014 Share on other sites More sharing options...
PFMaBiSmAd Posted May 25, 2011 Share Posted May 25, 2011 echo substr(date('c',strtotime("+ 2hours")), 0, 19); Link to comment https://forums.phpfreaks.com/topic/237432-datetime-help/#findComment-1220017 Share on other sites More sharing options...
JaredRitchey Posted May 25, 2011 Author Share Posted May 25, 2011 Thanks that works perfect! Link to comment https://forums.phpfreaks.com/topic/237432-datetime-help/#findComment-1220019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.