Lewis
Lewis

Reputation: 2188

Setting and stamping time on submit with php

I'm fairly green to PHP and I'm looking for a way to stamp time when a user, submits the form. I only want that time and not the current time. I have tried a few things like print, echo etc. But I can't seem to understand it properly.

Additionally to this my server time is returning a time that is an hour fast. I have tried to combat this with the following but no with no luck.

heres what I have;

// The following script only executes when the form is processed.
// set server timezone. declared at the top of my document.
  date_default_timezone_set("Europe/London" . '-1');

// set date & time. placed within my isset submit argument.
      $date = date ("l, F jS, Y");
      $time = date ("h:i A"); 

I'm currently calling the these variables with echo and EOD but, this is always giving me the server time even if the page is refreshed. I'm looking for a stamp of the time.

I'm echoing these variables out within an EOD and as a result, the print. command is being converted to simple text.

would anyone know of a quick fix to this or am I being a little too green?

Upvotes: 1

Views: 73

Answers (1)

Atrix
Atrix

Reputation: 299

In your script, try just:

date_default_timezone_set("Europe/London");

If that is the timezone you want your script to use.

Then on your server, make sure the server is set to use UTC (Coordinated Universal Time). That is a server set up issue.

https://www.devside.net/wamp-server/setting-the-default-timezone-for-php-to-use

Upvotes: 1

Related Questions