time-format

Javascript: convert 24-hour time-of-day string to 12-hour time with AM/PM and no timezone

孤人 提交于 2019-11-27 13:56:24
The server is sending a string in this format: 18:00:00 . This is a time-of-day value independent of any date. How to convert it to 6:00PM in Javascript? I could prepend today's date as a string to the value sent by the server and then parse the combined values and then try the .toTimeString() method of the Date object, but the format that time method emits is 24-hour time with a seconds chunk. I could write a function, but is there something built in? Nothing built in, my solution would be as follows : function tConvert (time) { // Check correct time format and split into components time =

Get Real Time - Not Device Set Time in android

最后都变了- 提交于 2019-11-27 08:50:51
How to find out the Real Geographical Time , as in my application I want to attach the real time with my application. So that if the user changes the time in his device then I should get only the real prevailing time - NOT THE DEVICE TIME My question is much confusing but try to understand in a simple language - I dont want DEVICE TIME, I want REAL PREVAILING TIME at any instant Gaurav Arora You need to use the NTP (Network Time Protocol) protocol: Here is some code I found somewhere else... and I am using it. This uses the Apache Commons library, which can be installed using Gradle (adding a

Format realtime stopwatch timer to the hundredth using Swift

懵懂的女人 提交于 2019-11-27 07:57:54
问题 I have an app using an NSTimer at centisecond (0.01 second) update intervals to display a running stopwatch in String Format as 00:00.00 (mm:ss.SS). (Basically cloning the iOS built-in stopwatch to integrate into realtime sports timing math problems, possibly needing millisecond accuracy in the future) I use (misuse?) the NSTimer to force-update the UILabel. If the user presses Start, this is the NSTimer code used to start repeating the function: displayOnlyTimer = NSTimer

Show Time in 12 and 24 hour format in UIDatepicker on the basis of app settings not on device Settings

我们两清 提交于 2019-11-27 04:25:14
问题 My problem is there is a switch in my app which toggles for 12 hour and 24 hour time format.I am displaying my labels time according to that, but the UIDatePicker time is not getting changed.It's time is depending on device time settings format.Is it possible to show time in UIDatePicker according to my app settings which might be different from device time settings. Somewhere I read that UIDatePicker respects only device settings but still I want to ask if it is possible to show time in 12

How to display a date as iso 8601 format with PHP

白昼怎懂夜的黑 提交于 2019-11-26 22:18:23
I'm trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it's coming out wrong. 17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969) This is the code I'm using: <?= date("c", $post[3]) ?> $post[3] is the datetime (CURRENT_TIMESTAMP) from my MySQL database. Any ideas what's going wrong? The second argument of date is a UNIX timestamp, not a database timestamp string. You need to convert your database timestamp with strtotime . <?= date("c", strtotime($post[3])) ?> Using the DateTime

How do I convert datetime to ISO 8601 in PHP

久未见 提交于 2019-11-26 21:38:19
How do I convert my time from 2010-12-30 23:21:46 to ISO 8601 date format? (-_-;) alex Object Oriented This is the recommended way. $datetime = new DateTime('2010-12-30 23:21:46'); echo $datetime->format(DateTime::ATOM); // Updated ISO8601 Procedural For older versions of PHP, or if you are more comfortable with procedural code. echo date(DATE_ISO8601, strtotime('2010-12-30 23:21:46')); After PHP 5 you can use this: echo date("c"); form ISO 8601 formatted datetime. http://ideone.com/nD7piL Note for comments: Regarding to this , both of these expressions are valid for timezone, for basic format

Javascript: convert 24-hour time-of-day string to 12-hour time with AM/PM and no timezone

社会主义新天地 提交于 2019-11-26 18:17:56
问题 The server is sending a string in this format: 18:00:00 . This is a time-of-day value independent of any date. How to convert it to 6:00PM in Javascript? I could prepend today's date as a string to the value sent by the server and then parse the combined values and then try the .toTimeString() method of the Date object, but the format that time method emits is 24-hour time with a seconds chunk. I could write a function, but is there something built in? 回答1: Nothing built in, my solution would

Get Real Time - Not Device Set Time in android

那年仲夏 提交于 2019-11-26 16:39:52
问题 How to find out the Real Geographical Time , as in my application I want to attach the real time with my application. So that if the user changes the time in his device then I should get only the real prevailing time - NOT THE DEVICE TIME My question is much confusing but try to understand in a simple language - I dont want DEVICE TIME, I want REAL PREVAILING TIME at any instant 回答1: You need to use the NTP (Network Time Protocol) protocol: Here is some code I found somewhere else... and I am

How to display a date as iso 8601 format with PHP

六眼飞鱼酱① 提交于 2019-11-26 08:14:12
问题 I\'m trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it\'s coming out wrong. 17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969) This is the code I\'m using: <?= date(\"c\", $post[3]) ?> $post[3] is the datetime (CURRENT_TIMESTAMP) from my MySQL database. Any ideas what\'s going wrong? 回答1: The second argument of date is a UNIX timestamp, not a database timestamp string. You

How do I convert datetime to ISO 8601 in PHP

女生的网名这么多〃 提交于 2019-11-26 08:01:55
问题 How do I convert my time from 2010-12-30 23:21:46 to ISO 8601 date format? (-_-;) 回答1: Object Oriented This is the recommended way. $datetime = new DateTime('2010-12-30 23:21:46'); echo $datetime->format(DateTime::ATOM); // Updated ISO8601 Procedural For older versions of PHP, or if you are more comfortable with procedural code. echo date(DATE_ISO8601, strtotime('2010-12-30 23:21:46')); 回答2: After PHP 5 you can use this: echo date("c"); form ISO 8601 formatted datetime. http://ideone.com