Hi, this morning I have seen that the script at
pagina: http://www.teachingonline.it/script/statistiche2.php
wasn't working properly
With this code I estract the day of the week in numeric format
$data=$record['Data_Visita']; // year-month-day date format
$anno=substr($d ata,1,4);
$mese=substr($d ata,6,2);
$giorno=substr( $data,8,2);
$utime = mktime (0,0,0, $mese,$giorno,$ anno,-1);
$weekday=date(' w',$utime);
if ($weekday==0)
$weekday=7; // days from 1 to 7 (in Italian)
echo $weekday;
This code has worked correctly before sept 30, after this day, I should
have had weekday=6, then 7, then 1 again, but after 5 I get 3, and so on
What is the problem?
Francesco
--
Teaching OnLine
Corsi online di programmazione
Php, Asp, C, C++, Visual Basic, Delphi
Linux Shell Programming
------------------------------------ http://www.teachingonline.it 2 2534 This code has worked correctly before sept 30, after this day, I should have had weekday=6, then 7, then 1 again, but after 5 I get 3, and so on
Interesting... there's some subtle change in behaviour with mktime()
that depends on whether you use leading 0's in the month. Changing from
September (month '09' in your code) to October (month '10') switches
from one behaviour to the other. The change involves making an
assumption about what day the week starts on (American vs European?)
So I think your code just needs to be adjusted to consistently force
the use of the second behaviour, by casting the month to an integer:
// $weekday: 1=Monday/Lunedi, 2=Tuesday/Martedi, ..., 7=Sunday/Domenica
$data=$record['Data_Visita']; // year-month-day date format
$anno = intval( substr($data,1, 4) );
$mese = intval( substr($data,6, 2) );
$giorno = intval( substr($data,8, 2) );
$utime = mktime(0,0,0, $mese,$giorno,$ anno,-1);
$weekday = date('w',$utime );
echo $weekday . "\n";
See the user note by <daykay at pdsoftware dot de> on the date()
manpage <http://www.php.net/manual/en/function.date.p hp>
---
Steve Steve
Thank you very much, Steve, I'll go to see just now.
Francesco
--
Teaching OnLine
Corsi online di programmazione
Php, Asp, C, C++, Visual Basic, Delphi
Linux Shell Programming
------------------------------------ http://www.teachingonline.it This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: adam |
last post by:
Hi all,
I am having a problem with calculating a date. What I am looking to do
is get the date of Sunday of this week, then use mktime() to find out
other days in the past by subtracting days.
In the code below, today is Saturday, October 16, 2004, this week's
Sunday is 2004-10-17. I successfully get that.
But, when I try to subtract 7 days using mktime(), I instead of getting
|
by: Bengt Richter |
last post by:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.mktime((1969, 12, 31, 17, 0, 0, 0, 0, 0))
3600.0
>>> time.mktime((1969, 12, 31, 17, 0, 0, 0, 0, 1))
0.0
>>> time.mktime((1969, 12, 31, 16, 0, 0, 0, 0, 1))
|
by: Florian Quetting |
last post by:
Hi,
I'm getting mad with following problem: The code compiles, but I always get
a segfault and I don't have any clue why. I can't see any differences in my
way of calling mktime and others.
---------------------------------------------------------------------------
#include <iostream>
#include <sys/stat.h>
|
by: McBooCzech |
last post by:
Hi, on Linux (Fedora FC4) and Python 2.4.1
I am trying to know the time delta in seconds between two times given
in the HHMMSS format. My code looks like:
import datetime, time
ta1=(time.strptime('000001', '%H%M%S'))
ta2=(time.strptime('230344', '%H%M%S'))
t1=time.mktime(ta1)
t2=time.mktime(ta2)
print t1, t2
|
by: KW |
last post by:
Hi all,
Appreciate if someone can help me out on this.
Currently, I have a tm structure holding information of the UTC time,
which is very likely to be in the past, meaning not the current time.
So, let's say I'm in CST(-6) now, and I want to know the equivalent
local time of that tm structure, how do I do that taking into
consideration daylight savings adjustments?
| |
by: John Hanley |
last post by:
I created a function that breaks down a date into broken down time, I
subtract a certain number of seconds from that, then use mktime() to
recompute the calendar time.
It works basically except every so often, I get the date 060207 (Feb 7,
2006) which is obviously not correct. When it does this it always gives me
this date.
I tracked it down to my mktime() call, when I get to a certain date, mktime
returns a number in 4000000000,...
|
by: Jorgen Bodde |
last post by:
Hi List
I am working on an app to store guitar songs I am practicing, and for
the fun of it I want to store the date of songs when they were
originally made. So far so good..
However, my taste of music is "Rag Time Blues" and that os OLD, very
OLD music. So it happened I entered a song from the date " 28 dec
1928".
|
by: John Hanley |
last post by:
I am getting some inconsistencies with mktime().
I allocate memory for my struct tm early in my program, and assign only
*some*
of the member variables.
t->tm_sec=s;
t->tm_min=m;
t->tm_hour=h;
t->tm_mday=d;
|
by: Robert Latest |
last post by:
Here's what happens on my Windows machine (Win XP / Cygwin) at work.
I've googled a bit about this problem but only found references to
instances where people referred to dates before the Epoch.
Of course at home on my Linux box everything works.
I know that everything has its limits somewhere, but I've never
heard of March 2008 being a problem.
Tomorrow I'm going to write a test loop that shows me the exact last
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |