Message Boards Message Boards

3
|
20898 Views
|
11 Replies
|
10 Total Likes
View groups...
Share
Share this post:

Convert 1040 Seconds Into 17 Minutes and 20 Seconds?

Posted 8 years ago

Hello,

I have a basic question which I cannot find the answer to: How do I make Mathematica convert 1040 seconds into 17 minutes and 20 seconds? I want Mathematica to give me the conversion with one command or cell input. I would also like for the output to have the words "minutes" and "seconds" if possible.

Thanks.

POSTED BY: Dan M
11 Replies

MixedRadix is no longer the proper form, as you can check here

Here is the most modern way:

UnitConvert[Quantity[1040, "Seconds"], MixedUnit[{"Minutes", "Seconds"}]]

17min 20s

POSTED BY: Rodrigo Murta
Posted 6 years ago

UnitConvert[ Quantity[Round[(5 45765)/$ProcessorCount, 60], "Seconds"], MixedRadix[{"Hours", "Minutes"}]]

Does not work on Linux (MATE Desktop Environment 1.12.1), returning $failed.

UnitConvert[ Quantity[Round[(time times)/$ProcessorCount, 60], "Seconds"], MixedRadix["Hours", "Minutes"]]

returns

Quantity[MixedMagnitude[{15, 53}], MixedUnit[{"Hours", "Minutes"}]]

POSTED BY: Simon Blank
Posted 6 years ago

With curly braces it does not work in mathematica 11.3 and in conjunction with ToString

POSTED BY: Simon Blank

Hi Simon,

could you please post the offensive code? The code in the posts above seems to work fine in my version of MMA 11.3 (OSX).

Best wishes,

Marco

POSTED BY: Marco Thiel

Does this work for you?

UnitConvert[Quantity[1040, "Seconds"], MixedRadix["Minutes", "Seconds"]]

Cheers,

M.

POSTED BY: Marco Thiel
Posted 8 years ago

Yes it does. Thanks for the help.

POSTED BY: Dan M
Posted 8 years ago

Does this work for you? UnitConvert[Quantity[1040, "Seconds"], MixedRadix["Minutes", "Seconds"]] Cheers, M.

M, I have been searching for an answer regarding conversion of seconds to minutes. Your answer made my day. Thanks, mate!

POSTED BY: Lingaria .
Posted 8 years ago

Curious how you came to MixedRadix rather than MixedUnit? Both work, but documentation does not show MixedRadix path. Thx!

POSTED BY: David Proffer

Hi David,

I don't know where that comes from. I had been using that before and new it would work. Perhaps it comes from StackExchange.

If you google UnitConvert and MixedRadix you get lots of hits. If I remember correctly MixedUnit was introduced after MixedRadix, so it might just have been an "old habit".

Sorry, that I cannot be more precise.

Cheers,

Marco

POSTED BY: Marco Thiel

When you type something like Quantity[700, "Minutes"], the suggestions bar will offer you to "convert to hours, mins, secs". Accept the offer to get

UnitConvert[Quantity[700, "Minutes"], MixedRadix["Hours", "Minutes", "Seconds"]]

Which by the way is an undocumented three argument call to MixedRadix

POSTED BY: Gustavo Delfino

Two ways are possible:

UnitConvert[Quantity[1040, "Seconds"], MixedRadix["Minutes", "Seconds"]]
UnitConvert[Quantity[1040, "Seconds"], MixedUnit[{"Minutes", "Seconds"}]]

Though the first shows up in red (incorrect syntax), but somehow works...

See also the examples that describe how to get mixed units:

Column[Join @@ ("PropertiesRelations" /. 
    WolframLanguageData[
     Entity["WolframLanguageSymbol", "UnitConvert"], 
     "DocumentationExampleInputs"])]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract