stevesimo Posted February 27, 2007 Share Posted February 27, 2007 Hi, I am fairly new to PHP and am not sure how I get the current date into a variable. The complication is that I am based in the UK but the server is based in America. Does anyone know how I would get around this problem. I have got the following code, is this valid? setlocale(LC_ALL, 'eng-GB'); $mydate = date(); Many thanks Steve (Blackpool) Link to comment https://forums.phpfreaks.com/topic/40377-american-date-problem/ Share on other sites More sharing options...
Tyche Posted February 27, 2007 Share Posted February 27, 2007 Almost right - the setlocale only impacts strftime not date try : $mydate=strftime('%c'); - time will still be local server time also date() requires a date formatting string - so you could use $mydate = date('r'); which will use the RFC 2822 date format e.g. Tue, 27 Feb 2007 12:53:07 +0500 for a US EST based server or use gmdate('r') to return the GMT time EDIT: Sorry not really thinking you can convert the date to UK format using $mydate=strftime('%d/%m/%Y'); To read 27/02/2007 Link to comment https://forums.phpfreaks.com/topic/40377-american-date-problem/#findComment-195366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.