I want to take only the hour from the date time field. For that first i apply the explode.[PHP]$Query1 = explode(" ",$row['Date']);[/PHP]
output:13:30:0013:30:0016:20:0016:20:00(This include hour:minutes:seconds)
And now i want to extract only first 2 digit(hour).
ex:13,13,16,16
HOw can i do that? Please help me.
3 9402
try
if the sql stores the date as a single int....
if the Date field is a String representation, you may like to first convert to a time object, using: -
$temp=strtotime($row['Date']);
-
$hour=date('h',$temp);
-
note: h will give you the hour in 12 hr format - H will give 24hr format
you could also try to extract the hour yourself by manipulating the string..... http://us3.php.net/date
try
if the sql stores the date as a single int....
if the Date field is a String representation, you may like to first convert to a time object, using: -
$temp=strtotime($row['Date']);
-
$hour=date('h',$temp);
-
note: h will give you the hour in 12 hr format - H will give 24hr format
you could also try to extract the hour yourself by manipulating the string..... http://us3.php.net/date
I did it. But got only 20. This is my code.[PHP]
$Date= "13:30:0013:30:0016:20:0016:20:00";
date('H',$row['Date']);
$temp=strtotime($row['Date']);
$hour=date('H',$temp);
echo "$hour";[/PHP]
Why are there 4 seperate Times in the field??
I think you will have to manipulate the string yourself....
firtunately, the field should always be the same size. You can use the php substr method which takes string, offset and lengh as arguments....eg, the first hour would be
the second would be
etc...
If you wanted to, you could store them all in an Array - and use a loop to calculate them....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Adams |
last post by:
My Access app stamps the date and time for each database entry.
I'd like to generate a report of:
- the number of entries per hour of day (0 - 23), and also
- the number of entries per day of...
|
by: mtech1 |
last post by:
Access 2003
I need to create a query to view data by 3 - 24 hour shifts. Ex: There
are 3 shifts, each shift is 24 hours starting at 0700 through 0700.
Each shift is designated as A, B, or C. ...
|
by: Pieter Coucke |
last post by:
Hi,
For some reason, somewhere in my application 1 hour is added to my dates,
depending in which time zone the application is run...
Because I don't have a clue where this happens, I posted this...
|
by: Summu82 |
last post by:
HI I have to convert a time in the format
i have
year
month
day
hour
min and seconds
I need to convert this into time in seconds since 1 jan 1970 i.e the
|
by: Shawn Yates |
last post by:
I have a database that I am using as a Time clock where employees can
clock in and out. Is there a way to make it so that when they clock
out a form would open displaying their work day hour by...
|
by: =?Utf-8?B?R2ls?= |
last post by:
I have a server (Win2k3 SBS) that is a domain controller and exchange server.
I failed to apply the DST patches until after the DST kicked in. I have
since completed successfully the patches and...
|
by: nex85 |
last post by:
hi!
HOUR FROM TIME
i) does anyone know how to determine which hour a time value lies in? the arrival time is in hh:mm:ss format. for e.g.: for an arrival time of 17:00:26, the correct conversion...
|
by: jonathan184 |
last post by:
Hi I am trying to do a script to monitor a dir where files pass through approx every 5 mins but sometimes files may not come in for hours
So the purpose of the script is to monitor by if no files...
|
by: ollyb303 |
last post by:
Hello,
Need some help with an Access 2000 query.
My query is based on a table which is a log of calls to my company.
I am using a date range entered by the user
(Date Between And )
and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |