Home » Web Design » Web Design – PHP Code – Server Date_Time

Web Design – PHP Code – Server Date_Time

This sample is using the Plugin “PHP Code for posts”. The link is found here.

php-serverdate_time
Note this plugin works similar to Watu Quizzes. You create your PHP code within the plugin, which provides you “snippets”, or shortcodes. You then past the short code in your WordPress post or page.

Current date and local time on this server is 2018-02-21 (Wed) 19:15:47

The outcome of this initial php code is above, php snippet=2.

.

$timestamp = time();

The function time() provides us the time value, which is placed in the variable $timestamp.
The time server is listening on TCP/UDP port 13 and sends an ASCII string (one line, no format defined)

$datum = date(“Y-m-d (D) H:i:s”,$timestamp);

The $datum is our variable for the full date and time.
date() is the function, while the parameters Y-m-d gives us our year-month-day.

 

echo “Current date and local time on this server is $datum <br>\n”

The echo is the easier part of identifying what is going on.
This provides our string, “Current date and local time on this server is
While the $datum is the variable containing the value of the date/time

 

An expanded explanation of the parameters/format within the DAYTIME are below.

  JJJJJ – the Julian Date is : 53746
YR-MO-DA – the Date is : 2006-01-11
HH:MM:SS – the Time in UTC is : 21:28:49
TT – Indication whether USA is on Standard Time (ST) or Daylight Saving Time (DST) : 00 (Standard Time)
L – Leap second at the end of the month (0: no, 1: +1, 2: -1) : 0
H – Health of the server (0: healthy, >0: errors) : 0
msADV – time code advanced in milliseconds to compensate network delays : 266.1
UTC(NIST) – the originator of this time code : UTC(NIST)
OTM – on-time marker : *


Leave a comment

Your email address will not be published. Required fields are marked *