473,756 Members | 4,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert milliseconds to a time

hello

I've tried to convert some milliseconds to a time format.

$ms = 100000 // 1min 40sec
echo strftime('%H:%M :%S', $ms/1000);

i expect the result is: "00:01:40"

but the result ist: "01:01:40"

i think this is a problem of a locale.
is there another easy way to covert a given ammout of milliseconds to a
time format?

thanks
//B

May 10 '06 #1
1 12654
"Benny Schudel" <be**********@g mail.com> wrote in message
news:11******** *************@j 73g2000cwa.goog legroups.com...
hello

I've tried to convert some milliseconds to a time format.

$ms = 100000 // 1min 40sec
echo strftime('%H:%M :%S', $ms/1000);

i expect the result is: "00:01:40"

but the result ist: "01:01:40"

i think this is a problem of a locale.
is there another easy way to covert a given ammout of milliseconds to a
time format?

strftime takes a pattern and a timestamp as parameter. The timestamp is
milliseconds since the EPOCH time, January 1, 1970 at midnight at GMT. Now
my guess is that the one hour leap comes from the fact that you live in a +1
timezone and the +1 hour is being accounted for when you use strftime. I
tried the same script and just as expected I got 02:01:40 since Helsinki is
in GMT+2 timezone.

I didn't test, but I'd guess the sisterfunction of strftime, gmstrftime
would do the trick since it assumes GMT time is being used and doesn't add
any timezone hours to the time. Therefore it might provide a solution.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
May 10 '06 #2

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

Similar topics

2
2321
by: amitkhemlani | last post by:
Hello All, I have data in the form of characters Ex: "Amit". I convert the data from its character representation to its ascii values so "Amit" gets converted to "97 109 105 116". I then convert the ASCII values to its bit representation. In the bit stream if i get a 1 I want to sound a beep for 1ms(milliseconds) with frequency 1350 Hz and if I get a 0 I want to sound a beep for 2ms at 2025 Hz. Knowing this information how to I...
6
1743
by: Richard Visser | last post by:
Hi, i've found this DateRangeSelector : http://www.petrafex.com/view/pgID/21/db/pages/date_range_selector_date_manip ulation__dates_.html . This works fine but i need it to send the dates as : yyyy-mm-dd or dd-mm-yyyy instead of the milliseconds it using now. I also want to get rid of the 'show calender' pop-ups, i just need the Date Range Selector dropdowns. There is a demo and a download. I'm a newbie to javascript, so can someone...
11
14583
by: S_at_work | last post by:
hello, can anybody give me a piece of code , or a hint , how i can recieve the time i need for connect() to another host in milliseconds. My problem is i want test the performance of ipsec, so i need the
9
7285
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
2
5391
by: Rajat | last post by:
Hi, I have to draw a real time chart in which I have several entries at the same second (i.e. HH:MM:SS:Milleconds) The charting component only takes julian date for drawing the dates. I am not able to convert the normal C# DateTime to juliandate which takes milliseconds along with hour,minute,second. All of the julian date implementations only take date + HH:MM:SS (upto second not milliseconds). Please help, how can I include the...
9
3685
by: Simple Simon | last post by:
Java longs are 8 bytes. I have a Java long that is coming in from the network, and that represents milliseconds since Epoch (Jan 1 1970 00:00:00). I'm having trouble understanding how to get it into a struct timeval object. I get the ByteBuffer as an array of const unsigned char, 'buffer'. Here's an example: 00 00 01 0A 29 1D 07 E4 This value maps somehow to Thu Mar 23 16:57:49 2006 and some
2
24236
by: vinodtr | last post by:
Hi all, I have a date which is represented by the number of milliseconds since January 01, 1970. I need to change this back to DATE format. Is there any built in function in DB2 to do the needed conversion ? In Oracle i was able to do the conversion by the following statement. select to_char(to_date('01/01/1970','mm/dd/yyyy'),'mm/dd/yyyy') + milliseconds/86400000) from dual; Note: In the above sql statement, milliseconds is the no:...
3
12272
by: vunet.us | last post by:
What is the best method to convert milliseconds (after midnight January 1, 1970 GMT) to formatted time example: 972798180000 ==10/18/2000 14:08:11
3
6355
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have various times formatted like 00:00:00, so for example, 01:32:05 would be one thirty-two with five milliseconds. I need to convert this into seconds (an integer). First of all, I have been unable to use the mid() function like I did in vb 6.
0
9431
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
9255
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
10014
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...
0
9844
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 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...
0
8688
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
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
6514
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
5119
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...
1
3780
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 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.