westman Posted December 15, 2011 Share Posted December 15, 2011 i know this may be so simple for most of you, however am still learning.am looking for a script that will automatically find the date on the next monday.this script will be ran every monday and i have this so fear...<?php$mydate = "2011, 12, 24";?> Link to comment Share on other sites More sharing options...
justsomeguy Posted December 15, 2011 Share Posted December 15, 2011 Look at the examples here: http://www.php.net/manual/en/function.strtotime.php Link to comment Share on other sites More sharing options...
westman Posted December 15, 2011 Author Share Posted December 15, 2011 got it <?php$day = date('d');$month = date('m');$year = date('Y');$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));echo $nextMonday;?> Link to comment Share on other sites More sharing options...
westman Posted December 15, 2011 Author Share Posted December 15, 2011 this code i have... <?php$day = date('d');$month = date('m');$year = date('Y');$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));echo $nextMonday;?> could some1 tell me what time is used here, the time from the users pc or server time.if it is the time from the users pc how do i get the time in London, UK? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 15, 2011 Share Posted December 15, 2011 PHP only uses the server settings. You can use date_default_timezone_set to set the default timezone. http://www.php.net/manual/en/function.date-default-timezone-set.php Link to comment Share on other sites More sharing options...
westman Posted December 16, 2011 Author Share Posted December 16, 2011 thank you Link to comment Share on other sites More sharing options...
westman Posted December 16, 2011 Author Share Posted December 16, 2011 hmmm am still lost how do i get this to use the time in London, UK? <?php$day = date('d');$month = date('m');$year = date('Y');$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));echo $nextMonday;?> ? Link to comment Share on other sites More sharing options...
birbal Posted December 16, 2011 Share Posted December 16, 2011 Did you check the link which justs0meguy provided above? Link to comment Share on other sites More sharing options...
westman Posted December 16, 2011 Author Share Posted December 16, 2011 i didphp dose not come easy to me Link to comment Share on other sites More sharing options...
birbal Posted December 16, 2011 Share Posted December 16, 2011 which part yoy are facing problem to understand?that above function will change its timezone everytime it is ivoked.date() has two parameters first one is the date format in string and second one is integer as timestamp. by default the timestamp is current timestamp. timestamp is timezone independent. so date will just output the date in the format which you have provided in first argument according to timezone which is already set in php.ini. date_default_timezone_set() will override the timezone everytime on script execution. and let the date() provide the date according to new timezone.manual page has fare amount of example with that Link to comment Share on other sites More sharing options...
westman Posted January 3, 2012 Author Share Posted January 3, 2012 so will this work?<?phpdate_default_timezone_set('Europe/London');$day = date('d');$month = date('m');$year = date('Y');$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));echo $nextMonday;?> Link to comment Share on other sites More sharing options...
thescientist Posted January 4, 2012 Share Posted January 4, 2012 have you tried it? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.