How to change the string in seconds to minutes in Swift3?

How to change the string in seconds to minutes in Swift3?

Content Index :

How to change the string in seconds to minutes in Swift3?
Tag : ios , By : alexmajy
Date : November 15 2020, 03:01 PM

may help you . Hi I am getting the value of time as a string. The number which i am getting is in the seconds. Now i want to convert the Seconds to minutes by using swift3. , Here is one method:
let duration: TimeInterval = 540

// new Date object of "now"
let date = Date()

// create Calendar object
let cal = Calendar(identifier: .gregorian)

// get 12 O'Clock am
let start = cal.startOfDay(for: date)

// add your duration
let newDate = start.addingTimeInterval(duration)

// create a DateFormatter
let formatter = DateFormatter()

// set the format to minutes:seconds (leading zero-padded)
formatter.dateFormat = "mm:ss"

let resultString = formatter.string(from: newDate)

// resultString is now "09:00"

// if you want hours
// set the format to hours:minutes:seconds (leading zero-padded)
formatter.dateFormat = "HH:mm:ss"

let resultString = formatter.string(from: newDate)

// resultString is now "00:09:00"
formatter.dateFormat = "hh:mm:ss a"
"12:09:00 AM"

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Python: Read text file with time in hour, minutes and seconds; and angle in degree, arc minutes and arc seconds

Tag : python , By : Jakub Filak
Date : March 29 2020, 07:55 AM
To fix the issue you can do Using matplotlib.dates.datestr2num you could easily convert your first column to plottable numbers, but I did not find a function for your second column. You can build a function to process that, though:
import numpy as np

def calc_hour( str ):
    hour, min, sec = [float(i) for i in str.split(':')]
    min += sec/60.
    hour += min/60.
    return hour

calc_hour = np.vectorize( calc_hour )

def calc_deg( str ):
    deg, min, sec = [float(i) for i in str.split(':')]
    min += sec/60.
    deg += min/60.
    return deg

calc_deg = np.vectorize( calc_deg )
values = np.loadtxt('tmp.txt', dtype=str)
hours= calc_hour( values[:,0] )
degs =  calc_deg( values[:,1] )
hours = array([ 0.10133333,  0.11713889,  0.23825   ,  0.38333333,  0.39730556,
                0.39844444,  0.39983333,  0.40102778,  0.40105556,  0.40108333,

degs = array([-70., -66., -59., -52., -49., -29., -28., -26., -14.,  25.,  30.])
import matplotlib.pyplot as plt

Converting time, after 60 seconds it is only displaying the minutes. I am trying to display minutes followed by seconds.

Tag : android , By : littlefuzz
Date : March 29 2020, 07:55 AM
it helps some times How do I display the seconds followed by the minutes like 1:20. Before the 60 seconds it displays the seconds but after the 60 seconds, it displays 1 mins. Following a tutorial but it is not what I am looking for. If you need more information let me know. , You could do like this
private String parseDuration(int durationInSeconds) {
    return String.format("%02dm :: ", durationInSeconds/60) + String.format("%02ds", durationInSeconds%60);

Parsing t=1h2m3s(h - hour, m-minutes, s-seconds ) into seconds if order of hours, minutes and seconds are valid

Tag : javascript , By : FuzzyHornet
Date : March 29 2020, 07:55 AM
may help you . I would first check that the order matches then, if it does calculate the time in seconds.
function calculateInSeconds(timeStamp) {
  var timeInSeconds=0;
  console.log("calculateInSeconds timeStamp:"+timeStamp);
    timeStamp.replace(/([0-9]+)[h|m|s]/g, function(match, value) {
       if (match.indexOf("h") > -1) {
          timeInSeconds += value * 60 * 60;
       } else if (match.indexOf("m") > -1) {
                timeInSeconds += value * 60;
       } else if (match.indexOf("s") > -1) {
                timeInSeconds += value * 1;
calculateInSeconds("t=1h2m");//3720 valid
calculateInSeconds("t=2m1h");//0 invalid

Change label text from Hours:Minutes:Seconds to Minutes:Seconds

Tag : chash , By : Terrence Poon
Date : March 29 2020, 07:55 AM
To fix the issue you can do if your time is string:then you can use :
lbltime.Text = time.Remove(0, 3);
lbltime.Text = mytime.ToString("mm:ss");

How to convert total seconds value to string in 'hours minutes seconds' format

Tag : chash , By : user106284
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • Why does the UIBarButtonItem not show up when I create it with code?
  • How to prevent following view controller inheriting navigation view controller bar?
  • What does it mean when .xcodeproj files are shown in red in Xcode?
  • Xcode SwiftUI how to scroll the Preview Canvas?
  • Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table c
  • xcodebuild failed with return code: 65 - using CLI/Appcenter but no error messages
  • "'isDeveloperModeEnabled' is deprecated: This no longer needs to be set during development. " What is isDevelo
  • Right click in UIKit for Mac
  • How we Support Dark Mode in Current iOS App with iOS 13?
  • Security vulnerablility issue in ios mobile app
  • How to set a background color for the viewController in swiftUI?
  • SwiftUI : Segue navigation
  • iOS 13 Custom UISearchBar _searchField crash
  • USDZ models have holes in SceneKit but not QuickLook
  • Why does iOS Password Autofill not prompt to save password on keychain?
  • Pushing information to firebase after event is created(Firebase-Realtime-Database)
  • Xcode 11 Beta and Carthage bootstrap
  • How to change the status bar background color and text color on iOS 13?
  • Using Core Data with SwiftUI
  • How should I do to wait all the data downloaded completely and show on TableView?
  • Can we specify the number of rows that can be shown in each section of a collection view
  • Why sometimes completion handler not called?
  • Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements
  • In UIKit we can set label.numberOfLines = 0 when we do not know how many lines the text will take? What is the alternati
  • Swift ISO8601 format to Date returning fatal error
  • SwiftUI Login Page Layout
  • Xcode: Could not locate installed application. Install claimed to have succeeded, but application could not be found on
  • See the TestFlight crash log in the Xcode
  • Why does zero UIView's CALayer.speed stops UIAlertController's buttons from working?
  • Firestore collectionGroup query returns empty result
  • Modify text in SwiftUI
  • CNCopyCurrentNetworkInfo with iOS 13
  • WWDC 2019 - iOS13 April 2020 requirement
  • Nativescript IPhone X - How to "hide" home indicator behind two swipes to go to home screen
  • Should I use a singleton location manager in Swift?
  • Accessibility problem in reusable TableViewCell
  • Remove top line containing Done button from Keyboard Using Storyboard or in Swift
  • Swift Storyboard - Centring an Icon and multi-line text horizontally
  • viewDidAppear is delayed by 0.5 sec
  • Pass URL values to SecondView Controller WebView (WKWebView)
  • How to upload images faster on iOS, when using takePictureAsync?
  • Tableview multiple sections with one floating header
  • UITextView: Huge Memory Usage
  • How to put a logo in NavigationView in swiftui?
  • How can I load an UIImage into a SwiftUI Image asynchronously?
  • How to remove highlight on tap of List with SwiftUI?
  • how to use customized toolbar in multiple viewcontroller without repeating the code and copying the elements (swift)?
  • iPhone 7 simulator is not found on Xcode 11 beta
  • SwiftUI view is in the middle instead of in the top
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com