DateWrapper.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * The DateWrapper allows easy handling of Flash dates
  4. *
  5. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  6. * @copyright (c) 2003 amfphp.org
  7. * @package flashservices
  8. * @subpackage util
  9. * @version $Id: DateWrapper.php,v 1.1 2005/03/24 22:19:48 pmineault Exp $
  10. */
  11. class DateWrapper
  12. {
  13. var $_date;
  14. /**
  15. * Contructor
  16. */
  17. function DateWrapper($input = "")
  18. {
  19. if(is_int($input) || is_float($input))
  20. {
  21. $this->_date = $input/1000;
  22. }
  23. else
  24. {
  25. $this->_date = time();
  26. }
  27. }
  28. /**
  29. * Get date according to client timezone
  30. */
  31. function getClientDate()
  32. {
  33. return $this->_date + DateWrapper::getTimezone();
  34. }
  35. /**
  36. * Get date according to server timezone
  37. */
  38. function getServerDate()
  39. {
  40. return ($this->_date + date("Z"));
  41. }
  42. /**
  43. * Get raw date
  44. */
  45. function getRawDate()
  46. {
  47. return $this->_date;
  48. }
  49. /**
  50. * Set utc date
  51. */
  52. function setDate($input)
  53. {
  54. $this->_date = $input;
  55. }
  56. /**
  57. * Get timezone
  58. */
  59. function getTimezone($val=NULL)
  60. {
  61. static $timezone = 0;
  62. if($val != NULL)
  63. {
  64. $timezone = $val;
  65. }
  66. return $timezone;
  67. }
  68. /**
  69. * Set timezone
  70. */
  71. function setTimezone($val=0){
  72. return DateWrapper::getTimezone($val);
  73. }
  74. }
  75. ?>