duanmangxie7131 2015-04-13 19:56
浏览 20
已采纳

如何在php中将用户选择的日期更改为服务器的当前周日期?

Hello i am working with a small application where user selects a week day from this select option:

   <select name="selectOption" class="dropdown-select">
      <option value="">Select a day!</option>
      <option value="Monday">Monday</option>
      <option value="Tuesday">Tuesday</option>
      <option value="Wednesday">Wednesday</option>
      <option value="Thursday">Thursday</option>
      <option value="Friday">Friday</option>
      <option value="Saturday">Saturday</option>                            
   </select>

When i store it in a variable i get this : $selectedDay = $_POST['selectOption']; //Monday,Tuesday etc. From this point i want to convert this day into server's current week date. For example when a user selects Thursday i want to convert it into 16-04-2015 because it is the current week's date for Thursday. It should only work for the current week. I could have used date picker straight forward but i want it to happen this way. Can anyone help?

  • 写回答

1条回答 默认 最新

  • dpbrrczhlwbv849228 2015-04-13 20:02
    关注

    You can use strtotime() and date():

    echo date('d-m-Y', strtotime('this Thursday'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line