strtotime - Output of last week's date in PHP different between localhost and server -


i want previous monday (last week) , end of last week (sunday) when code runs on server different when it's run on localhost.

this code:

$start_past = strtotime("last week");  $end_past = strtotime("+6 day",$start_past);  echo $start_past_qry = date("m/d/y",$start_past); echo $end_past_qry = date("m/d/y",$end_past); 

results on localhost

  • 05/06/2013
  • 05/12/2013

results on server

  • 05/13/2013
  • 05/19/2013

the results on server seems fall under current week. want last week range.

from php manual

http://php.net/manual/en/function.strtotime.php

each parameter of function uses default time zone unless time zone specified in parameter. careful not use different time zones in each parameter unless intended. see date_default_timezone_get() on various ways define default time zone.

you need define default timezone can done function

date_default_timezone_set()

list of supported time zones

also pay attention that:

prior php 5.3.0, relative time formats supplied time argument of strtotime() such week, previous week, last week, , next week interpreted mean 7 day period relative current date/time, rather week period of monday through sunday.

be sure have same php version , @ least 5.3.0 check manual of strtotime function know more details


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -