我有一个如下代码的时间戳。
$time=time();
请解释我如何从中制作自定义日期。
答案 0 :(得分:1)
请参阅此处的文档:http://php.net/manual/en/function.date.php
string date(string $ format [,int $ timestamp = time()])
举个例子:
echo date('Y-m-d', $time);
答案 1 :(得分:0)
请使用这样的php内置日期功能。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Complexity;
use App\Rating;
use Session;
class RatingController extends Controller
{
public function setRating(Request $request){
if(Session::getId() == $request->get('session_id')){
if(session()->has('rating')){
$rating = session()->get('rating');
}else{
$rating = new Rating();
}
}else{
$rating = new Rating();
}
$rating->mystery_id = $request->get('mystery_id');
$rating->rating = $request->get('rating');
$rating->save();
session()->put('rating' , $rating);
return json_encode(['rating' => $rating]);
}
public function setComplexity(Request $request){
if(Session::getId() == $request->get('session_id')){
if(session()->has('complexity')){
$complexity = session()->get('complexity');
}else{
$complexity = new Complexity();
}
}else{
$complexity = new Complexity();
}
$complexity->mystery_id = $request->get('mystery_id');
$complexity->rating = $request->get('rating');
$complexity->save();
session()->put('complexity' , $complexity);
return json_encode(['complexity' => $complexity]);
}
}
我希望你明白。