473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Time convert problem

Hi there,

I get form a database time with the format : 'Jan 01 1900
06:00PM'

I want to convert it to :HH:MM
I tryed it with $heure=(date("H:i",strtotime($row[0]))
but I get allways 20:55. even when time changes. Whats wrong ?

Does anybody know where I can get a good function which will convert date to
date and time to time with different formats ?

Thanks in advance for any help

Best regards

Ralf

Jul 17 '05 #1
3 2305
its because its not a php timestamp.

A quick search of google, revealed this;

http://php.codenewbie.com/articles/p...mp-Page_1.html

- Ali

"Ralf Meuser" <rm*****@free.fr> wrote in message
news:42***********************@news.free.fr...
Hi there,

I get form a database time with the format : 'Jan 01 1900
06:00PM'

I want to convert it to :HH:MM
I tryed it with $heure=(date("H:i",strtotime($row[0]))
but I get allways 20:55. even when time changes. Whats wrong ?

Does anybody know where I can get a good function which will convert date
to date and time to time with different formats ?

Thanks in advance for any help

Best regards

Ralf

Jul 17 '05 #2
Ralf Meuser wrote:
Hi there,

I get form a database time with the format : 'Jan 01 1900
06:00PM'

I want to convert it to :HH:MM
I tryed it with $heure=(date("H:i",strtotime($row[0]))
but I get allways 20:55. even when time changes. Whats wrong ?

Does anybody know where I can get a good function which will convert date
to date and time to time with different formats ?


No, but wouldn't a simple substr(...) + check for AM/PM suffice?

C.
Jul 17 '05 #3
NC
Ralf Meuser wrote:

I get form a database time with the format : 'Jan 01 1900 06:00PM'
What type is the database field? DATETIME?
I want to convert it to :HH:MM
I tryed it with $heure=(date("H:i",strtotime($row[0]))
but I get allways 20:55. even when time changes. Whats wrong ?
Since strtotime() returns and unsigned Unix timestamp, it can only
work with dates after the Unix epoch (January 1, 1970).
Does anybody know where I can get a good function which will convert
date to date and time to time with different formats ?


You can format time on the database server:

SELECT DATE_FORMAT(your_time_field, '%H:%i') as formatted_time
FROM your_table;

Cheers,
NC

Jul 17 '05 #4

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

Similar topics

3
by: Jan Schmidt | last post by:
Hi NG, i've got a mystic problem i can't solve, perhaps one of you has a good idea... i will explain with some code, so fo better understanding my probroblem: i'll use asp, but for testing the...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
1
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...
5
by: simon_s_li | last post by:
Hi, I need to add 48 hours to a specific date (datetime data type) then check if the time is past 5pm. So for example the time is 7pm. If this is the case I need to set the time to 5pm the...
3
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a...
8
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my...
4
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is...
17
by: Andrew Chalk | last post by:
Network time uses 1900 as its base. The C time library uses 1970. I want to convert a network time value to a C library time. I.e. I have to subtract the number of seconds from 1900 to 1970. Is...
3
by: Liming | last post by:
Hello All, In our project management software, we just noticed an issue. If team members are across the world, then there is an issue with due dates being consistent. (even though we have not...
14
by: shapper | last post by:
Hello, Is there any function to convert a Date/Time from UTC to the user client zone and back from user client zone to UTC? I want to store Date/Time in UTC in the database but display it in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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,...
0
jinu1996
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...

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.