Need to display date time when email was sent

Hi all
Im just writing some code which generates an email to the client using php mail. He wants the date/time to display within the body of an email.
How can I use php to grab the date/time fo when that code was executed?
Thanks

https://www.php.net/manual/en/function.date.php

Thanks. Ive just tried that but its an hour too early. Is that becuase its getting the server’s time?

https://www.php.net/manual/en/function.date-default-timezone-set.php

Yes. See the link @igor_g just posted on how to change the timezone of PHP to match the timezone you’re in.

Thanks guys - works like a charm now!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.