In my php application I got the date and time as two separate values.(User entered value)
ex:date =06-07-2008
time =16:10
I want to combine those two values and convert the date format like the following. 2008-07-03 14:08:16
How can I do that. Could you please help me?
This is my code.
[PHP]
$message = $_GET['message'];
$mn=split(" ",$message);
echo "$mn[0]<br>";
echo "$mn[1]<br>";
[/PHP]
Current out put
06-07-2008
16:10
8 7497
1.) Why are you putting the <br> if you don't want the strings to be split?
2.) You can concatenate strings using the dot (.) operator.
3.) Why did the time part change from 16 ... to 14 ...?
1.) Why are you putting the <br> if you don't want the strings to be split?
2.) You can concatenate strings using the dot (.) operator.
3.) Why did the time part change from 16 ... to 14 ...?
If I didn't put <br> I got the out put 06-07-200816:10. I want to put a space between date and time. Also date should be 2008-07-06.
My final out put should be 2008-07-06 16:10
If I didn't put <br> I got the out put 06-07-200816:10. I want to put a space between date and time. Also date should be 2008-07-06.
My final out put should be 2008-07-06 16:10
Browse this list and pick the most appropriate functions to use. Try the code and post again if you still have problems.
Heya, ghjk.
What is the value of $_GET['message']? From your code and output, it looks like it's already formatted the way you need...?
Try something like this: -
$date = date('Y-m-d H:i:s', strtotime($_GET['message']));
-
Heya, ghjk.
What is the value of $_GET['message']? From your code and output, it looks like it's already formatted the way you need...?
Try something like this: -
$date = date('Y-m-d H:i:s', strtotime($_GET['message']));
-
Spoil sport
I Did That. DT=06-08-2008 15:02
[PHP]
$Da = substr("$DT ", 0, 2);
$Mn = substr("$DT", 3, 2);
$Ye = substr("$DT ", 6, 4);
$Ho = substr("$DT", 10, 2);
$Mi = substr("$DT ", 13, 2);
$Date = $Ye."-".$Mn."-".$Da." ".$Ho.":".$Mi;
[/PHP]
I Did That. DT=06-08-2008 15:02
[PHP]
$Da = substr("$DT ", 0, 2);
$Mn = substr("$DT", 3, 2);
$Ye = substr("$DT ", 6, 4);
$Ho = substr("$DT", 10, 2);
$Mi = substr("$DT ", 13, 2);
$Date = $Ye."-".$Mn."-".$Da." ".$Ho.":".$Mi;
[/PHP]
Edit : Also check out pb's version.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steve Jorgensen |
last post by:
Hi all,
I'm working on the schema for a database that must represent data about stock
& bond funds over time. My connundrum is that, for any of several dimension
fields, including the fund name...
|
by: Jamie Pittman via AccessMonster.com |
last post by:
I have two tables with 5000 entries on them. One is based for regular time
with several variables example (employee name, date,time in and out, code,
customer, building) I have another table that...
|
by: jhutchings |
last post by:
Hello everyone,
I have a database where I collect shipment data from various tables.
However, I have a problem. Whenever I want to see shipping data for
orders that were set to ship on or before...
|
by: rdraider |
last post by:
Hi all,
We have an app that uses SQL 2000. I am trying to track when a code field
(selcode) is changed on an order which then causes a status field (status)
to change. I tried a trigger but...
|
by: Luvin lunch |
last post by:
Hi,
I'm new to access and am very wary of dates as I have limited
experience in their manipulation and I know if they're not done
properly things can turn ugly quickly.
I would like to use a...
|
by: drurjen |
last post by:
Good morning.
I am importing an XLS file into one of my tables. The fields are:
Date Id Time IO
12/22/2006 2 12:48:45 PM 9
12/22/2006 16 5:40:55 AM 1
12/22/2006 16 12:03:59 PM 2
...
|
by: TIonLI |
last post by:
I am working with a table that lists dates and corresponding times in separate fields. For purposes of building a query to calculate elapsed time I would like to combine a field with a field ending...
|
by: csolomon |
last post by:
Hello:
I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them...
|
by: ghjk |
last post by:
In my php application user should enter date and time separately. But i want to combine them to compare with database value. How can i do that?
user input Date:2008-03-25
User input time:11:30
Eg;...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: 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...
|
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,...
| |