001.
002.
003.
function
generate_date_today(
$Format
,
$Timestamp
,
$Language
=
"en"
,
$TimeText
= true )
004.
{
005.
global
$SuffixTime
,
$DateThai
;
006.
007.
if
(
date
(
"Ymd"
,
$Timestamp
) >=
date
(
"Ymd"
, (time()-345600)) &&
$TimeText
)
008.
{
009.
$TimeStampAgo
= (time()-
$Timestamp
);
010.
011.
if
((
$TimeStampAgo
< 86400))
012.
{
013.
014.
$TimeDay
=
"time"
;
015.
016.
if
(
$TimeStampAgo
< 60)
017.
{
018.
$Return
= (time() -
$Timestamp
);
019.
$Values
=
"Seconds"
;
020.
}
021.
else
if
(
$TimeStampAgo
< 3600)
022.
{
023.
$Return
=
floor
( (time() -
$Timestamp
)/60 );
024.
$Values
=
"Minutes"
;
025.
}
026.
else
027.
{
028.
$Return
=
floor
( (time() -
$Timestamp
)/3600 );
029.
$Values
=
"Hours"
;
030.
}
031.
032.
}
033.
else
if
(
$TimeStampAgo
< 172800)
034.
{
035.
$Return
=
date
(
"H:i"
,
$Timestamp
);
036.
$TimeDay
=
"day"
;
037.
$Values
=
"Yesterday"
;
038.
}
039.
else
040.
{
041.
$Return
=
date
(
"H:i"
,
$Timestamp
);
042.
$TimeDay
=
"day"
;
043.
$Values
=
date
(
"l"
,
$Timestamp
);
044.
}
045.
046.
if
(
$TimeDay
==
"time"
)
047.
$Return
.=
$SuffixTime
[
$Language
][
$TimeDay
][
$Values
];
048.
else
if
(
$TimeDay
==
"day"
)
049.
$Return
=
$SuffixTime
[
$Language
][
$TimeDay
][
$Values
] .
$Return
;
050.
051.
return
$Return
;
052.
}
053.
else
054.
{
055.
if
(
$Language
==
"en"
)
056.
{
057.
return
date
(
$Format
,
$Timestamp
);
058.
}
059.
else
if
(
$Language
==
"th"
)
060.
{
061.
$Format
=
str_replace
(
"l"
,
"|1|"
,
$Format
);
062.
$Format
=
str_replace
(
"D"
,
"|2|"
,
$Format
);
063.
$Format
=
str_replace
(
"F"
,
"|3|"
,
$Format
);
064.
$Format
=
str_replace
(
"M"
,
"|4|"
,
$Format
);
065.
$Format
=
str_replace
(
"y"
,
"|x|"
,
$Format
);
066.
$Format
=
str_replace
(
"Y"
,
"|X|"
,
$Format
);
067.
068.
$DateCache
=
date
(
$Format
,
$Timestamp
);
069.
070.
$AR1
=
array
(
""
,
"l"
,
"D"
,
"F"
,
"M"
);
071.
$AR2
=
array
(
""
,
"l"
,
"l"
,
"F"
,
"F"
);
072.
073.
for
(
$i
=1;
$i
<=4;
$i
++)
074.
{
075.
if
(
strstr
(
$DateCache
,
"|"
.
$i
.
"|"
))
076.
{
077.
078.
079.
$split
=
explode
(
"|"
.
$i
.
"|"
,
$DateCache
);
080.
for
(
$j
=0;
$j
<
count
(
$split
)-1;
$j
++)
081.
{
082.
$StrCache
.=
$split
[
$j
];
083.
$StrCache
.=
$DateThai
[
$AR1
[
$i
]][
date
(
$AR2
[
$i
],
$Timestamp
)];
084.
}
085.
$StrCache
.=
$split
[
count
(
$split
)-1];
086.
$DateCache
=
$StrCache
;
087.
$StrCache
=
""
;
088.
empty
(
$split
);
089.
}
090.
}
091.
092.
if
(
strstr
(
$DateCache
,
"|x|"
))
093.
{
094.
095.
$split
=
explode
(
"|x|"
,
$DateCache
);
096.
097.
for
(
$i
=0;
$i
<
count
(
$split
)-1;
$i
++)
098.
{
099.
$StrCache
.=
$split
[
$i
];
100.
$StrCache
.=
substr
((
date
(
"Y"
,
$Timestamp
)+543), -2);
101.
}
102.
$StrCache
.=
$split
[
count
(
$split
)-1];
103.
$DateCache
=
$StrCache
;
104.
$StrCache
=
""
;
105.
empty
(
$split
);
106.
}
107.
108.
if
(
strstr
(
$DateCache
,
"|X|"
))
109.
{
110.
111.
$split
=
explode
(
"|X|"
,
$DateCache
);
112.
113.
for
(
$i
=0;
$i
<
count
(
$split
)-1;
$i
++)
114.
{
115.
$StrCache
.=
$split
[
$i
];
116.
$StrCache
.= (
date
(
"Y"
,
$Timestamp
)+543);
117.
}
118.
$StrCache
.=
$split
[
count
(
$split
)-1];
119.
$DateCache
=
$StrCache
;
120.
$StrCache
=
""
;
121.
empty
(
$split
);
122.
}
123.
124.
$Return
=
$DateCache
;
125.
126.
return
$Return
;
127.
}
128.
}
129.
}
130.
131.