質問編集履歴

5

訂正

2019/04/30 17:56

投稿

raisinchan
raisinchan

スコア14

test CHANGED
File without changes
test CHANGED
@@ -36,15 +36,15 @@
36
36
 
37
37
  // 基本となる日時
38
38
 
39
- $base = ceil(microtime(true)*1000);
39
+ $base = ceil( microtime(true)*1000 );
40
40
 
41
- $date = $base/1000;
41
+ $date = $base / 1000;
42
42
 
43
43
 
44
44
 
45
45
  // サイト閲覧者の応じた時差
46
46
 
47
- function time_difference($country){
47
+ function time_difference ($country ){
48
48
 
49
49
  if( $country=="cy" ){ return +8; }
50
50
 
@@ -56,11 +56,11 @@
56
56
 
57
57
  // 時差に応じた日時
58
58
 
59
- $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
59
+ $country = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) ;
60
60
 
61
- $country_date = $date . time_difference($country);
61
+ $country_date = $date . time_difference( $country ) ;
62
62
 
63
- $result = date("Y/m/d H:i:s",$date);
63
+ $result = date( "Y/m/d H:i:s", $country_date ) ;
64
64
 
65
65
 
66
66
 

4

訂正

2019/04/30 17:56

投稿

raisinchan
raisinchan

スコア14

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
  $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
60
60
 
61
- $country_date = $date - time_difference($country);
61
+ $country_date = $date . time_difference($country);
62
62
 
63
63
  $result = date("Y/m/d H:i:s",$date);
64
64
 

3

訂正

2019/04/30 17:54

投稿

raisinchan
raisinchan

スコア14

test CHANGED
File without changes
test CHANGED
@@ -34,9 +34,11 @@
34
34
 
35
35
  ```ここに言語を入力
36
36
 
37
- // 基本となる数字
37
+ // 基本となる日時
38
38
 
39
39
  $base = ceil(microtime(true)*1000);
40
+
41
+ $date = $base/1000;
40
42
 
41
43
 
42
44
 
@@ -54,8 +56,6 @@
54
56
 
55
57
  // 時差に応じた日時
56
58
 
57
- $date = $base/1000;
58
-
59
59
  $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
60
60
 
61
61
  $country_date = $date - time_difference($country);

2

訂正

2019/04/30 17:53

投稿

raisinchan
raisinchan

スコア14

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- ・たとえ時差が取得できても、それをどのようにして$dateから加減するのか?
29
+ ・たとえ時差が取得できても、それをどのようにして$dateから計算するのか?($country_dateではその計算ができませんでした)
30
30
 
31
31
 
32
32
 

1

ソースコードの一部訂正

2019/04/30 17:52

投稿

raisinchan
raisinchan

スコア14

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- country_time(); で時差を返し、その時差に応じて「Y/m/d」を出力したいのですが、どのようなソースコードになりますでしょうか?
15
+ time_difference(); で時差を返し、その時差に応じて「Y/m/d」を出力したいのですが、どのようなソースコードになりますでしょうか?
16
16
 
17
17
 
18
18
 
@@ -34,15 +34,15 @@
34
34
 
35
35
  ```ここに言語を入力
36
36
 
37
+ // 基本となる数字
38
+
37
39
  $base = ceil(microtime(true)*1000);
38
40
 
39
41
 
40
42
 
41
- $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
43
+ // サイト閲覧者の応じた時差
42
44
 
43
-
44
-
45
- function country_time($country){
45
+ function time_difference($country){
46
46
 
47
47
  if( $country=="cy" ){ return +8; }
48
48
 
@@ -52,14 +52,20 @@
52
52
 
53
53
 
54
54
 
55
+ // 時差に応じた日時
56
+
55
57
  $date = $base/1000;
56
58
 
59
+ $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
57
60
 
61
+ $country_date = $date - time_difference($country);
58
62
 
59
63
  $result = date("Y/m/d H:i:s",$date);
60
64
 
61
65
 
62
66
 
63
- echo $result; // サイト閲覧者の時差に応じて「Y/m/d」を出力したい
67
+ // サイト閲覧者の時差に応じて「Y/m/d」を出力したい
68
+
69
+ echo $result;
64
70
 
65
71
  ```