Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Pandaboy · Sep 18, 2011 at 05:54 AM · timerealtimeos

Getting the current real life time?

Hi! I've looked a bit in the scripting reference manual, especially around the Time class. I'm looking to find a way to get the current real life time, for example the time of the clock on the computer, like 14:34, or even just time of the day in seconds. All I could found was "time since game start", which is not what i want. Any ideas?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BerggreenDK · Sep 18, 2011 at 09:52 AM 0
Share

Google.com still works mate:

http://www.google.com/search?q=current+time+.net+unity3d

avatar image Pandaboy · Sep 22, 2011 at 10:29 PM 0
Share

I used google, but I was dumb enough to search for "unity3d real life time", which didn't work quite well x).

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by ShinAli · Sep 18, 2011 at 09:20 AM

Don't forget that you also have the Mono system libraries at hand (mostly an implementation of .NET 3.5). There is a structure under the System namespace called DateTime, with it a member called Now which returns a DateTime structure of the current time. So, in code:

 // in C#
 using System;
 DateTime now = DateTime.Now;
 
 // in JavaScript (forgive me if this is wrong, I don't use JS often)
 var now : System.DateTime;
 now = System.DateTime.Now;

For more information to the DateTime structure, refer to the .NET library documentation over here or the Mono System library documentation over here.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image berk_can · Oct 22, 2017 at 07:24 AM 0
Share

Doesn't time value co$$anonymous$$g from net function change when device time is set manually?

avatar image
0

Answer by Krayt · Sep 18, 2011 at 08:16 AM

Took me a bit to remember how to do this...this next bit of code will basically create a variable of Type DateTime (available under the System namespace - not System.Collections) and then output the time to the console. You can do alot with this class and any objects instantiated from it, so you play around with the formatting til you get something you can use.

 System.DateTime myTime =  System.DateTime.Now;
         Debug.Log(myTime.TimeOfDay);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

realtimeSinceStartup resets during application shutdown 0 Answers

Real time and slider values 1 Answer

How to Count quited(program off) time 1 Answer

create a pause state and menu that still allows animations 0 Answers

How to change my stop watch code into real time? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges