Jump to content

Difference between time in PHP and in WinCC Data.


sm2106

Recommended Posts

Hi, I have a problem.
I have some data stored by WinCC, and I want to read them in PHP. If i do that i get data in UTC time. What Shoud i do to fix it?
I'm not good in PHP.

Part of code in PHP:

$tn[0]="TAG:R,'Agregat_MOC\MOC','".$data_P." 00:00:00.001','".$data_K." 23:59:59.001'.',TIMESTEP=86400,261'";//srednia z dnia OK


This is how it looks like

$tn[0]="TAG:R,'Agregat_MOC\MOC','2015-08-01 00:00:00.001','2015-08-31 23:59:59.001'.',TIMESTEP=86400,261'";//srednia z dnia OK


This is how it should looks like

$tn[0]="TAG:R,'Agregat_MOC\MOC','2015-07-31 22:00:00.001','2015-08-31 21:59:59.001'.',TIMESTEP=86400,261'";//srednia z dnia OK

Im in europe/warsaw timezone (it includes winter/summer time changing)

Link to comment
Share on other sites

The problem is that I need to have reports from WinCC
I have some data stored in WinCC. I want to see some value let say X. I have this value in WinCC database at  2015-07-31 22:00:00.001 and the same value in php at 2015-08-01 00:00:00.001.
Probably the problem is that I have UTC time in PHP. But i do  not know.
Here is the rest of code with "time"
Unfortunately in polish
 

$rok = $_POST['rok'];
echo $rok;
$miesiac = $_POST['miesiac'];
echo $miesiac;
$_SESSION['rok'] = $rok;
$_SESSION['miesiac'] = $miesiac;

$data = new datetime($rok.'-'.$miesiac.'-01');
$data_P = $data->format('Y-m-d');
$_SESSION['dzien_p'] = $data_P;
$interwal_m = new dateinterval('P1M');
$interwal_d = new dateinterval('P1D');
$data->add($interwal_m);
$data_K = $data->format('Y-m-d');
$data->sub($interwal_d);
$data_K = $data->format('Y-m-d');
$_SESSION['data_k'] = $data_K;
$d_ost = $data->format('d');
$_SESSION['dzien_ost'] = $d_ost;

function mkmatrix($rows,$cols){
         $count = 1;
         $mk = array();
         for ($i=0;$i<$rows;$i++){
             for ($j=0;$j<$cols;$j++){
             $mk[$i][$j]=$count++;
             }
         }
return($mx);
}
$m1 = mkmatrix(31,52);

settype ($sPro, "string");
settype ($sDsn, "string");
settype ($sSer, "string");
$sPro = "Provider=WinCCOLEDBProvider.1;";
$sDsn = "Catalog=CC_ExternalBrowsing;";
$sSer = "Data Source=.\WinCC";

$sCon = $sPro.$sDsn.$sSer;
$conn = New COM("ADODB.Connection");
$conn->ConnectionString = $sCon;
$conn->CursorLocation = 3;
$conn->Open();
$oRs = New COM("ADODB.Recordset");
$oCom = New COM("ADODB.Command");
$oCom->CommandType = 1;
$oCom->ActiveConnection = $conn;
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.