Jump to content

Date/Time Help


JaredRitchey

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.