php.ini (in C:\xampp\php\) date.timezone = Asia/Taipei

Slides:



Advertisements
Similar presentations
Week 8 - Friday.  What did we talk about last time?  String to int conversions  Users and groups  Password files.
Advertisements

Php – 日期與時間 php.ini (in C:\xampp\php\) date.timezone = Asia/Taipei.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Includes and Dates.
Interacting with Unix. Getting the Process ID u Synopsis #include pid_t getpid(void); u Example: #include int main(){ pid_t n = getpid(); printf("Process.
Slide 1 PHP Predefined Functions ITWA113. Murach’s ASP.NET 3.5/C#, C1© 2008, Mike Murach & Associates, Inc. Slide 2 PHP Predefined Functions Objectives.
Working with Date and Time ISYS 475. How PHP processes date and time? Traditional way: – Timestamp Newer and object oriented way: – DateTime class.
Week 9 - Wednesday.  What did we talk about last time?  structs.
PRÁCE S ČASEM V PHP. DATE  string date ( string $format [, int $timest amp = time() ] )  echo date('l jS \of F Y h:i:s A');  Monday 8th of August 2005.
CALENDAR YEAR PLAN JANUARY FEBRUARY MARCH APRIL MAY JUNE.
PREPOSITIONS OF TIME. IN USE in months Year Seasons part of the day Duration EXAMPLES in July; in September in 1985; in 1999 in summer; in the summer.
September 1 st Sunny Monday Date 日期 Weather 天氣 Days of the Week 星期 Year 年.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own.
Le jour et la date The day and the date.
Built-in Functions.
Ethan & Fletcher’s Day Day of the week Time Date Day / Month / Year 12
Week 9 - Wednesday CS222.
Calendar 2017.
JavaScript Arrays Date
Abbreviations.
Days of the Week Les docs d’Estelle –
Time Revision.
Second Grade Saxon Math Lesson 30A
DAYS OF THE WEEK.
Fun with dates and calendars
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
Spelling this week!
Year 2 Autumn Term Week 12 Lesson 1
Calendar of 2012 ESL Lesson on Months.
A Class Calendar in PowerPoint
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Calendar 2012 Example text here.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
DAILY ROUTINES.
Good day class! Good ________ Ms. A!.
Fun with dates and calendars
MY FUNDAY.
EMPLOYER TESTING On-Going Employees (one who has been with the employer for at least one standard measurement period) STANDARD MEASUREMENT PERIOD 3 – 12.
L3 D1 Drills How old are you? When is your birthday?
SEPTEMBER ½ Day Start Unit 1
SEPTEMBER 2014 Unit 1 Unit 1 Continued Unit 1 Continued
Year 2 Autumn Term Week 12 Lesson 1
Unit 1: Quick Quizzes After 5,13
Web Programming Language
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
What’s the date today?.
SEPTEMBER 2014 Unit 1 Unit 1 Unit 1 Unit 1 Quick Quiz 9,16, 21 Unit 1
Events (start and stop and duration)
SEPTEMBER ½ Day Unit PLC
Created by: Ramona Lewis-Dailey
Dot the Days Calendar Activity CATHY JONES
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Numbers Time By 張映芬老師.
Extended Christmas Hours Thursday December 8th 9am -6:30pm Friday December 9th 9am -6:30pm Saturday December 10th 9am-6pm Thursday December.
January 2015 Sunday Monday Tuesday Wednesday Thursday Friday Saturday
WHEN IS YOUR BIRTHDAY? IT’S ON THE 5TH (FIFTH) OF MAY.
| January Sunday Monday Tuesday Wednesday Thursday Friday
JUNE 2010 CALENDAR PROJECT PLANNING 1 Month MONDAY TUESDAY WEDNESDAY
WELCOME.
Contact
Created by: Ramona Lewis-Dailey
NOVEMBER READING LOG Student: When you have read, record your minutes and have your parent initial the proper box (each day). At the end of the month,
DECEMBER READING LOG Student: When you have read, record your minutes and have your parent initial the proper box (each day). At the end of the month,
閨怨 ~王昌齡 閨中少婦不知愁, 春日凝妝上翠樓; 忽見陌頭楊柳色, 悔教夫婿覓封侯。.
What’s the date today?.
Write the date in English
Reviewing Abbreviations
WHEN IS YOUR BIRTHDAY? IT’S ON THE 5TH (FIFTH) OF MAY.
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
Presentation transcript:

php.ini (in C:\xampp\php\) date.timezone = Asia/Taipei

getdate() 取得日期時間 array getdate ([時間戳記] ) Key Description Example returned values "seconds" Numeric representation of seconds 0 to 59 "minutes" Numeric representation of minutes "hours" Numeric representation of hours 0 to 23 "mday" Numeric representation of the day of the month 1 to 31 "wday" Numeric representation of the day of the week 0 (Sunday) through 6 (Saturday) "mon" Numeric representation of a month 1 through 12 "year" A full numeric representation of a year, 4 digits Examples: 1999 or 2003 "yday" Numeric representation of the day of the year 0 through 365 "weekday" A full textual representation of the day of the week Sunday through Saturday "month" A full textual representation of a month, such as January or March January through December Seconds since the Unix Epoch, similar to the values returned by time() and used by date(). -2147483648 ~ 2147483647

Example <?php echo "getdate() 函式的使用<hr />"; $nowTime = getdate(); foreach($nowTime as $Key => $Value) { echo "$Key => $Value <br />"; } ?> $nowTime = getdate(); $year = $nowTime['year']; $mon = $nowTime['mon'];

localtime() array localtime ([ 時間戳記], [ 是否associative] ) 說明: http://www.php.net/manual/en/function.localtime.php tm_sec = 33 tm_min = 59 tm_hour = 22 tm_mday = 23 tm_mon = 4 tm_year = 113 tm_wday = 4 tm_yday = 142 tm_isdst = 0 0 = 33 1 = 59 2 = 22 3 = 23 4 = 4 5 = 113 6 = 4 7 = 142 8 = 0 May 23, 2013, 10:59 pm <?php $localtime = localtime(); $localtime_assoc = localtime(time(), true); foreach ($localtime as $key => $val) { echo "$key = $val<br/>"; } echo "<hr/>"; foreach ($localtime_assoc as $key => $val) { ?>

gettimeofdate() array gettimeofdate() Array keys: "sec" - seconds since the Unix Epoch "usec" - microseconds "minuteswest" - minutes west of Greenwich "dsttime" - type of dst correction <?php echo "<hr />gettimeofday() 函式的使用<hr />"; $nowTime = gettimeofday(); foreach($nowTime as $Key => $Value){ echo "$Key => $Value <br />"; } ?>

date() string date ( 格式字串 [, 時間戳記 ] ) 例: 格式字串說明: http://www.php.net/manual/en/function.date.php 例: $today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm $today = date("m.d.y"); // 03.10.01 $today = date("j, n, Y"); // 10, 3, 2001 $today = date("Ymd"); // 20010310 $today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01 $today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day. $today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001 $today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month $today = date("H:i:s"); // 17:16:18

time() int time() 取得時間戳記,"January 1 1970 00:00:00 GMT"至今之秒數 $today=time(); echo "Today is ".date("Y-m-d", $today)."<br/>"; $nextWeek = time()+ (7 * 24 * 60 * 60); echo "Next week is ".date("Y-m-d", $nextWeek)."<br/>"; Today is 2012-05-31 Next week is 2012-06-07

mktime() My birthday is Mon 1982-06-07. int mktime(時, 分, 秒 , 月, 日, 年, 是否夏季節約) $birth = mktime(0,0,0, 6, 7, 1982); echo "My birthday is ".date("D Y-m-d", $birth).".<br/>"; My birthday is Mon 1982-06-07.

int strtotime() echo date("Y-m-d", strtotime("now")), "<br/>"; echo date("Y-m-d", strtotime("10 September 2000")), "<br/>"; echo date("Y-m-d", strtotime("+1 day")), "<br/>"; echo date("Y-m-d", strtotime("+1 week")), "<br/>"; echo date("Y-m-d", strtotime("+1 week 2 days 4 hours 2 seconds")), "<br/>"; echo date("Y-m-d", strtotime("next Thursday")), "<br/>"; echo date("Y-m-d", strtotime("last Monday")), "<br/>"; 2018-12-10 2000-09-10 2018-12-11 2018-12-17 2018-12-19 2018-12-13 2018-12-03

checkdate() bool checkdate(日, 月, 年) 2012 是閏年 2018不是閏年 檢查日期是否存在 <?php $thisYear = date("Y"); $isLeap= checkdate(2, 29, $thisYear); if ($isLeap) echo "$thisYear 是閏年"; else echo "$thisYear 不是閏年"; ?> 2012 是閏年 2018不是閏年