PC Nerd Posted July 23, 2008 Share Posted July 23, 2008 Hi, As the subject says, I'm attempting to find the timestamp of the beginning and the end of a month baed on another timestamp. eg: If i have the timestamp given by time();, then how would i find the timestamps for the beginning and end of tht month, or that week? Thanks Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/ Share on other sites More sharing options...
xtopolis Posted July 23, 2008 Share Posted July 23, 2008 possibly the getdate() function http://us.php.net/manual/en/function.getdate.php takes a timestamp as an argument, returns an associative array of more [delicious] information. Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597068 Share on other sites More sharing options...
PC Nerd Posted July 23, 2008 Author Share Posted July 23, 2008 ok - thanks. Im faced with the issue that i cant see a getgmdate(); function anywhere. Also, what woudl you say is the most efficient way to build my systen on GMT time, and then convert the displayed times into local time for the user. I can store whatever value is needed int eh database - im yet to build the form that stores receives the data. Would you recomend storing a GMT+-? value, or store a timezone abbreviation to use with strtotime()? etc? Im also using this to create charts based on database data and the current time ( phpclasses gantt chart class if people here have used it).... so it will also be adjusted to local time for the user. Any suggestion? Thanks Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597400 Share on other sites More sharing options...
unkwntech Posted July 23, 2008 Share Posted July 23, 2008 I would store the +/-GMT, and store all the dates/times in GMT Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597403 Share on other sites More sharing options...
PC Nerd Posted July 23, 2008 Author Share Posted July 23, 2008 ok - thanks... how should i then convert that together? Ill use gmdate(); and gmmktime(); etc, however im confused as to how i would convert to local time. see if i store "+1400" or "-0730", is there a function i can use that will accept that and the other time? or do i have to use string clicing etc to get teh data out end eveluate it: eg: first character is "+" then: echo $gmTime + substr(1, 5)*60*60; etc? thanks Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597432 Share on other sites More sharing options...
unkwntech Posted July 23, 2008 Share Posted July 23, 2008 Just store +/-8 instead of +/-0800 and do this: <?php $offset = mysql_result($result, 0, 'offset'); $time = date('Y-m-d H:i:s', mktime(date('H') $offset)) ?> Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597435 Share on other sites More sharing options...
PC Nerd Posted July 23, 2008 Author Share Posted July 23, 2008 what about those half timezones that i know there certainly are... as well as day light savings etc....? they would need to be 1000, -0830 etc ? Link to comment https://forums.phpfreaks.com/topic/116109-how-to-find-the-month-or-week-based-on-a-timestamp/#findComment-597439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.