473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need helps with date and time in PHP/MySQL


Hi folks,
I need help regarding date and time comparison in PHP and MySQL
My website is hosted in the USA (GMT - 8)
And It is managed in Madagascar (GMT + 3)
Want to consider DATE in Madagascar not in USA -
MySQL CONVERT_TZ's function doesn't work

So, how can I do the following:
1. Today's visits
$query = "SELECT count(*) FROM visits WHERE now() = date";

2. Articles on the website appear only after 6 AM (GMT +3) compared to
the date_publicatio n
$query = "SELECT n_edition FROM $table WHERE NOW() >
DATE_SUB(date_p ublication, INTERVAL 16 HOUR) ORDER BY n_edition DESC
LIMIT 1" ;

I don't know how to use DATE_ADD and DATE_SUB regarding the problem
below.
Notes that either visits.date and editions.date is recorded on the
server GMT -8

Any help could be appreciated

Nov 20 '06 #1
1 1631
rija wrote:
Hi folks,
I need help regarding date and time comparison in PHP and MySQL
My website is hosted in the USA (GMT - 8)
And It is managed in Madagascar (GMT + 3)
Want to consider DATE in Madagascar not in USA -
MySQL CONVERT_TZ's function doesn't work

So, how can I do the following:
1. Today's visits
$query = "SELECT count(*) FROM visits WHERE now() = date";

2. Articles on the website appear only after 6 AM (GMT +3) compared to
the date_publicatio n
$query = "SELECT n_edition FROM $table WHERE NOW() >
DATE_SUB(date_p ublication, INTERVAL 16 HOUR) ORDER BY n_edition DESC
LIMIT 1" ;

I don't know how to use DATE_ADD and DATE_SUB regarding the problem
below.
Notes that either visits.date and editions.date is recorded on the
server GMT -8

Any help could be appreciated
Since you're asking about MySQL operations and not PHP, might I suggest
you ask in comp.database.m ysql - where all the MySQL users hang out?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3722
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB my filed "date" in table "experience" is like this: Y-m-d (2002-07-23). My fied`date` is date, NOT NULL with no default entry My form read well the date data depending the id, (pe. 30.02.2003), but when I submit a new date, I receive as result...
3
3322
by: Noyb | last post by:
How do I convert a string into a value I can upload to mysql date field. Specifically, I have a user select a month, day and year from drop-downs, then I want them submitted to one date field. Thanks! Steve.
3
1848
by: JA | last post by:
I am trying to pull a time stamp out of a database,looks like this 2004-06-24 10:12:03 . Then I need to substring it so that I can take a difference of 2 times. Basically I making a clock in/clock out script for my job. But I can't figure out the query and then how to substring the time so that I can do math with just the time part and not the date. Or if you guys/gals no if any code out there, were someone has written a script like...
1
508
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time store in the database. However asp recognizes the data type as date and displays the date instead of the time. If I change the data type in mysql to varchar then asp will display the time correctly, but I cannot do it this way. I want to be able...
7
2883
by: Charles Crume | last post by:
Hello all; I have used dBASE, and other computer languages/databases, for years. They all have a logical field type. However, the version of MySQL used by the ISP hosting my site does not support a "logical" field type. It does support ENUM and I have set some up in a couple of tables that accept the values 'T' and 'F'. Sometimes they work like a logical field: if ($myrow) echo 'New';
3
2652
by: parksch2 | last post by:
I have been trying and trying to properly sort records through a mySQL query. I have hour, minute and AM/PM values stored separately in a database as varchars. I'm trying to concat those, cast them to a time value and sort them. I have found that it sorts some properly but other it does not. The following query: CAST(CONCAT(hour, ':', minute, ' ', ampm) AS TIME) AS myTime ORDER BY myTime
1
5079
by: Rotsj | last post by:
Hi, i'm using visual foxpro 9 with a mysql 5 database, for direct access to my database i use navicat. In visual foxpro i've set my date format to dd-mm-yyyy, also i did this in navicat. However when i insert a date into my database i have to insert it with the format yyyy-mm-dd. Is this a setting in mysql or is there another reason? Thanks. Rotsj.
6
3933
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
8
2979
by: Path9898 | last post by:
hello, i need some help with getting time out of a mysql db. I have a page that lets you enter in your name and submit to a mysql db. In the db the table row is called appt_time and has a Datatype of TIME, with default value of '00:00:00'. this works fine to get the time the record is entered, I do not need the date at all. A sample of the data is 'G .Beck', 14:30:00 Then i have a seperate page that gets this data, but the time suddenly...
0
8421
marktang
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...
0
8325
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,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8518
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,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.