dqwh0108 2019-02-19 11:05
浏览 37

在履行php响应中更改日期语言

Im tryng to create a response fulfillment in php, but my problem is change the language of month result. I set the php webhook with setlocale, but google assistant always response in english.

header( 'Access-Control-Allow-Headers: *' );
header( 'Access-Control-Allow-Origin: *' );
header( "Access-Control-Allow-Credentials: true" );
header( 'Content-Type: application/json' );
$postdata = file_get_contents( "php://input" );
$input = json_decode( $postdata, true );
setlocale (LC_TIME, 'it_IT.utf8','ita'); 
$intent = $input[ 'queryResult' ][ 'intent' ][ 'displayName' ];
$giorno = $input[ 'queryResult' ][ 'parameters' ][ 'giorno' ];
$guest = $input[ 'queryResult' ][ 'parameters' ][ 'guest' ];
$telefono = $input[ 'queryResult' ][ 'parameters' ][ 'telefono' ];
$tempo = $input[ 'queryResult' ][ 'parameters' ][ 'time' ][ 0 ];
$nome = $input[ 'queryResult' ][ 'parameters' ][ 'nome' ];
$oggi = date( "d F", strtotime($giorno) );

echo "{
    'fulfillmentText': 'Grazie " . $nome . ", ti confermo la tua prenotazione per ".$guest." persone alle ore " . substr( $tempo, -14, 5 ) . " del giorno " . $oggi . ".',
    'fulfillmentMessages': [
            {'text':
            {'text':
            ['Grazie " . $nome . ", ti confermo la tua prenotazione per ".$guest." persone alle ore " . substr( $tempo, -14, 5 ) . " del giorno " . $oggi . ".']
        }}],
    'source':'webhook'
}"

What nI have to change to get month name in italian?

  • 写回答

2条回答 默认 最新

  • drfkl66684 2019-02-19 11:36
    关注

    You should try to use strftime function

    $oggi = strftime( "%e %B", strtotime($giorno) );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?