- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要在 x 轴上的折线图中显示当前星期的日期。
我需要获取从今天开始的一周前的日期。前任。如果今天是 7 号,我需要获取从 1 号到 7 号的值数组形式的日期。我是 php 新手,想要一个简单易懂的解决方案。这是我的 js 显示折线图..
$(function () {
$('#container1').highcharts({
title: {
text: '',
x: -20 //center
},
/*subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},*/
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: ''
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Total Requirements',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
},{
name: 'Requirements with no Submissions',
data: [1.5, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
},{
name: 'Requirements to which Profiles were Submitted',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
我需要日期数组才能将它们发送到类别,而不是其中的默认值并显示在 x 轴上。我尝试了这个东西,但它给了我一些不需要的值,而且只有当周是在本周的中间,而不是移动到前一周,需要计算 7 天。
<?php
$dt = new DateTime();
$dates = [];
for ($d = 1; $d <= 6; $d++) {
$dt->setISODate($dt->format('o'),
$dt->format('W'), $d);
$dates[$dt->format('D')] = $dt->format('m-d-Y');
$string=implode(",",$dates);
echo $string;
}
?>
如果今天是第七天,无论星期几,我的输出必须是 10/1 10/2 10/3 ... 10/7。
最佳答案
您可以尝试这个,首先获取今天的日期,然后根据您的需要向后或向前运行循环。
P.S: 如果您要使用不同的时区进行管理,则需要进行 UTC 偏移等。
$date=date_create(DATE("d-m-Y"));
$array=[];
array_push($array, date_format($date,"m/j"));
for($i=7;$i>0;$i--)
{
date_sub($date,date_interval_create_from_date_string("1 days"));
array_push($array, date_format($date,"m/j"));
}
echo json_encode(array_reverse($array));// or you can do echo json_encode($array) to return json
根据您描述的输出,您将需要更改日期格式,因此请使用
更改代码array_push($array, date_format($date,"m/j"));
你将得到以下输出
["10\/7","10\/8","10\/9","10\/10","10\/11","10\/12","10\/13","10\/14"]
当前日期是 10 月 14 日
关于javascript - 我想在 php、JS 或 Jquery 中获取相对于当前日期的上周日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40034983/
我想检索上周和 15 周前的数据。 注意: 仅 15 周前的同一工作日,而不是其间的所有数据。例如,我想要 15 周前的每个星期四的数据。 这是我的 MySQL 表的简化,具有所需的结果。 Stati
我正在寻找一种基于以下条件选择行的方法: 本周 (S-S) 上周 (SS) 我遇到的问题是专门从Sunday-Sunday中选择。 目前我正在使用: SELECT SUM(time) FROM `ti
我有一个包含以下数据的 SQL 表: select day, counter from table1 where day LIKE '%201601%'; +----------+---------+
我有一个包含 3 列的表格:id、updated_at、click_sum。 许多行具有完全相同的 updated_at 值,这使得很难简单地检索数据、按 update_at 排序并在图表中显示总和。
我有一个 orders 表,其中包含 orderID 和 order_date。 我想查询上周、上个月甚至昨天的数据,但是我不知道如何从当前时间中减去时间 我的 order_date 字段是 TIME
在我的 iTunes connect 开发者资料中,我看到了与上周相比的变化,就在它的下方,售出单位数量旁边显示有变化。这个“变化”是什么?这是有多少人卸载了该应用程序? 最佳答案 不是,是上周下载量
我正在做一些统计,我想选择(仅上周)和本周的时间。 本周很简单: $start = strtotime('this week'); $finish = time(); 上周 $start = strt
前言 本文主要介绍的是关于利用python 获取本周,上周,本月,上月,本季的时间,话不多说了,来一起看看实现的方法吧 示例代码: ?
查询当前这周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m
我需要设置上周、上个月更改下拉列表的时间段 我正在做 switch (DDL.SelectedIndex) { case 0:
使用此查询: date(timestamp_column) >= SUBDATE(curdate(), WEEKDAY(curdate())) - interval 1 week AND date(t
我的 Android SQLite 数据库中有这个表: CREATE TABLE statistics (subject TEXT, hits INTEGER, fails INTEGER, date
目录 1、总结 一句话总结:使用mktime()函数即可:PHP mktime() 函数用于返回一个日期的 Unix 时间戳。 1、mktime()如何获取昨天的开始时间和结束时间? 2、
我需要显示有关Kibana的报告,该报告将基于多个日期间隔汇总结果。时间与时间戳一起映射为浮点数据类型。 例: Jobs, Yesterday, Last Week, Last Quarters Jo
我有一个名为 sales 的表,如下所示: s.no item_sold date 1 soap 25.07.2017 2
我想做的是让 NSDate 今天、昨天、本周、上周、本月、上个月变量准备好进行比较,以便在 UITableView 的 titleForHeaderInSection 上添加标题 我想要的是在下面的代
所以,我想做的是实现一个数据范围选择,它不显示两个日期选择器“从”和“到”。我想让用户在今天、昨天、上周、上个月等之间进行选择。 我在服务器端的应用程序中有类似的东西,但是: 1- 代码看起来很糟糕;
我是一名优秀的程序员,十分优秀!