Sometimes you need to know the current time on your site, which may differ from your local time. This can be done by running a script written in any of the server-side programming languages. Almost any hosting company that hosts sites offers customers the ability to use PHP (Hypertext Preprocessor). This is perhaps the easiest language to use, its capabilities and we will use it to solve the problem of determining the time on your site (more precisely, on the server of your site).
Instructions
Step 1
In general, the function that reads the current date and time from the server variables in PHP looks like this: date () This function must be specified in what format it should represent the result of its work. If you write it like this: date ('H: i: s dmY'); Then the function will generate the current date and time as follows: 19: 09: 06 2011-15-05 In the format that you specified ('H: i: s dmY '): - the letter H indicates that in the first place the hours should be displayed in the format we are accustomed to - from 00 to 23, and the number of one digit will be preceded by 0 (for example - 07). If you replace H with G, then this zero will not be added. And if you change the case of these letters (i.e. replace H and G with h and g), then the hours will be represented in the format 0 - 12. That is, 19 hours will be represented as 7 o'clock in the afternoon; - letter i marks the position, by which the minutes should be displayed; - the letter s indicates the location of the seconds in the date / time; - the letter d indicates that this position should contain the day of the month in two-digit format (for example - 09). If you replace with j, then the format of numbers less than 10 will become unambiguous (that is, not 09 but just 9); - letter m indicates the location of the month in the format from 01 to 12. Replacing it with n will change the format to 1.. 12 If you use the letter F, the full name of the month will be used (for example, "January"). And the letter M converts the full name to an abbreviated one (ie "Jan" instead of "January"); - the letter y means the full, four-digit representation of the year. Changing the case (y) will shorten the year to the last two digits (ie instead of 2011 it will become 11); This function has several more useful options, for example, the letter I allows you to find out if daylight saving time is currently in effect on the server. The letter O displays the server's time zone, that is, the offset in hours relative to Greenwich Mean Time. The letter W allows you to calculate the ordinal number of the week in the year, and w and D represent the current day of the week in digital and text form. You can even add to the date format displaying information about whether it is a leap year (letter L).
Step 2
Now you can move on to the practical part. Step 1: In any text editor (for example, in Notepad) create a new document. Step 2: Write a script into it from a single line of PHP code: Make sure the "<" icon is the very first character on the page that is, there are no blank lines or spaces in front of it. Step 3: From all the information about the possible date / time formats, come up with the format that works best for you, and replace the corresponding characters within the quotes in the code. Step 4: Save a document with the php extension (for example - date.php) and upload it to your site. That's all, now, by typing in the browser the address of the loaded page of your site, you will receive the current time and date on the server of your site.