cancel
Showing results for 
Search instead for 
Did you mean: 

How to get system time and date with PHP

Former Member
0 Kudos

Dear Mr.Craig,

Thanx a lot. We are running SRM 5.0 (RAMP - Implementation).

My initial requirement is to write a server-side script to display server date and time. Could you give more inside on how to achieve it?

Regards,

Deva.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

So I understand, you want to write a PHP script which will show the server (your SRM server) date and time?

Former Member
0 Kudos

Yes. Initial requirement is to do so.

Former Member
0 Kudos

Since this is PHP specific I moved it over here to the PHP forum.

Are you familiar with ABAP? Transaction SE37 in your system? You need to go there and you can do a time or date and hit F4 this will search all the available function modules on your system for one that you can access to give you the info.

Former Member
0 Kudos

For example typing in datetime* and hitting F4 I find

MSS_GET_SY_DATE_TIME

If I run that (just a quick test) I see the time and date of my system.

It has two export parameters SAPDATE and SAPTIME

Former Member
0 Kudos

Perhaps that will help.

[code]

<html>

<h1>Access System time and date</h1>

<?

// saprfc-class-library

require_once("saprfc.php");

$sap = new saprfc(array(

"logindata"=>array(

"ASHOST"=>"localhost" // application server

,"SYSNR"=>"00" // system number

,"CLIENT"=>"000" // client

,"USER"=>"bcuser" // user

,"PASSWD"=>"minisap" // password

)

,"show_errors"=>false // let class printout errors

,"debug"=>false)) ; // detailed debugging information

$result=$sap->callFunction("MSS_GET_SY_DATE_TIME",

array( array("EXPORT","SAPTIME",array()),

array("EXPORT","SAPDATE",array())));

if ($sap->getStatus() == SAPRFC_OK) {

echo "Time: ".$result["SAPTIME"];

echo "<br>Date: ".$result["SAPDATE"];

echo "<br>or<br>";

echo "Server is showing: "

.substr($result["SAPDATE"], 0, 4)

."-".substr($result["SAPDATE"], 4, 2)

."-".substr($result["SAPDATE"], 6, 2)

." and "

.substr($result["SAPTIME"], 0, 2)

.":".substr($result["SAPTIME"], 2, 2)

.":".substr($result["SAPTIME"], 4, 2);

} else {

$sap->printStatus();

}

$sap->logoff();

?>

[/code]

Former Member
0 Kudos

Dear Mr.Craig,

I worked with it. I coded inside my Intenet Service BBPSTART and HTML template BBPGLOBAL_300, but it doens't work. I changed those logon parameters before testing it.

Thanx a lot. Working with PHP should be interesting.

Rather I tried it working with SSI (Server-Side Includes). I tested it over the default website running at port 80 (with all the administration needed at server end to execute SSI's), it worked fine. But I keep guessing on how to enable SSI's inside SRM application server, which is running on port 8000. So I cudn't work find a way out.

Still struggling.

Regards,

Deva.

Former Member
0 Kudos

writing your own incredible function module would help to avoid future problems if the implementation of the MSS-function module gets changed. Here it is


FUNCTION ZTW_TIME.
*"-------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     VALUE(SYSTEMDATE) TYPE  SY-DATUM
*"     VALUE(SYSTEMTIME) TYPE  SY-UZEIT
*"-------------------------------------------------------

systemdate = sy-datum.
systemtime = sy-uzeit.

ENDFUNCTION.

johna69
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Deva,

Can you give more details on your setup please. From what I understand so far you are trying to get the date and time to show in the SRM pages. To achieve this you want to run a PHP script on the SRM server which is running ITS? Did you install PHP on there?

Regards

JohnA

Former Member
0 Kudos

Hi,

I was wondering if you could help. We have a PHP application that is calling SAP using SAPRFC. Unfortunately we need to change the target SAP IP address (the server has changed), but we don't know where this needs to change (the user who developed this application is no longer with the company).

Any help is appreciated.

Thanks.

JP

Former Member
0 Kudos

hi JP,

from a distance you can't exactly tell where the server address is saved. but ...

- mabe the app contains an admin section where the IP is being set; search the applicqation for a suitable link for admin login or seach the application's folder structure for an admin login page

- PHP-scripts are uncompiled text files. go to the folder of the application and simply do a textsearch for the old IP across all application files.

- the IP might not be hardcoded but be saved in a database. either examine the database for a suitable table holding config information or search again across all application files for a string like

$rfc = saprfc_open (array ("ASHOST"=>$server,"SYSNR"=>"20","CLIENT"=>"400",
                                               "USER"=>"test", "PASSWD" =>"test"));

$server would be the variable holding the IP adress. Analyze the file (and possible includes) to find out how $server is retrieved.

hope it helps,

anton

Former Member
0 Kudos

Hi,

Thanks very much for the reply.

I found it in a sapconf.xml file.

Thanks.

JP

Former Member
0 Kudos

you're welcome. glad you solved the problem. cheers, anton