shortysbest Posted March 25, 2011 Share Posted March 25, 2011 I want to have a couple of different formats from mktime(), which the value could be: 1292183335. I would like to have some of the formats like: Tuesday at 12:00am, Wednesday, January 12, 2011 at 12:00am Also taking different timezones in consideration. I'm not sure what to use for that. Link to comment https://forums.phpfreaks.com/topic/231698-php-mktime-to-format-tuesday-january-2-2011-at-1205pm/ Share on other sites More sharing options...
linus72982 Posted March 25, 2011 Share Posted March 25, 2011 date('l jS \of F Y h:i:s A T', mktime()); That will format the current mktime into the format you wanted (with the addition of the abbreviated timezone, you can take that out by removing T from the first argument.) If you want to convert a timestamp already in a variable to the same format, just replace the mktime() portion to your timestamp variable (or just enter the timestamp.) I *think* that if you haven't set a default timezone for php, it defaults to the server timezone, from there I would think you can just add or minus hours based on the timezone you want. I have a utility function I include in scripts that I send a timestamp to and it sends back an array with all the different timezones in it, so if I wanted a timezone in EST, I send it something like: $this->timeConv = $this->utils->convTime($timestamp) echo $this->timeConv['EST']; You can also have that array contain values for the day, month, year, etc individually and then formatted in different ways and a few ways that is formatted altogether (I have one that is fullDate and then fullDateTime and fullTime, etc) - anyway, just a thought. Link to comment https://forums.phpfreaks.com/topic/231698-php-mktime-to-format-tuesday-january-2-2011-at-1205pm/#findComment-1192300 Share on other sites More sharing options...
linus72982 Posted March 25, 2011 Share Posted March 25, 2011 Oh, by the way, check http://us3.php.net/manual/en/function.date.php to see all the formatting options for the date function. Link to comment https://forums.phpfreaks.com/topic/231698-php-mktime-to-format-tuesday-january-2-2011-at-1205pm/#findComment-1192301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.