Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 ramonfr · Apr 27, 2012 at 03:28 PM · .netdatetimedate

Get date from server?

Here comes a .NET question:

I need to save in a database the current date when the player registered, or something else.

But I want to record the "real" date, not the user machine's date, as he could easily change this date.

So I need to record the date from a reference outside the user's machine, maybe from a server, how could I do this?

(The function System.DateTime.Now gives me the client machine's date)

I thought I could create a PHP script that gets the current date from the server, then I could read the date from that page. Is there something wrong with this method? Are there any alternatives?

Comment
Add comment · Show 5
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 Lo0NuhtiK · Apr 27, 2012 at 03:58 PM 0
Share

Been quite awhile since I've messed with my DB , but if I remember right when I was setting it up there was a field I could put in there specifically for the date and it would automatically set itself whenever a new entry was made in that table. e.g. new user registered, it saved their name and password and all that junk by way of code ; but auto-saved the date it happened.
You should check in yours if you can do that.
...Edit Yeah, I just checked. If you can in yours, make a column of the type 'timestamp' in your users table and set it's default value to be "CURRENT_TI$$anonymous$$ESTA$$anonymous$$P" .

avatar image ramonfr · Apr 27, 2012 at 05:19 PM 0
Share

Yes, thanks, but there's a new problem:

I can set only one CURRENT_TI$$anonymous$$ESTA$$anonymous$$P as default for each table.

I need to record the last login date too.But I can do it simply updating the column with the CURRENT_TI$$anonymous$$ESTA$$anonymous$$P function.

Ps.: I'm using $$anonymous$$ySQL.

avatar image Lo0NuhtiK · Apr 27, 2012 at 05:46 PM 0
Share

maybe current_timestamp was what I used for last login... i think it might update every time that row of the table is updated, so that wouldn't be good for the registered date ; I can't remember exactly what I did for that stuff it's been so long. All I checked earlier was made a new table and added a couple columns to it and inserted something into the 2nd column to see if the timestamp field auto-filled lol ... but yeah, let the cur-ts set itself for last logins, then just include a part in your registration code PHP to set the registered date once. ---this isn't really unity specific lol but whatever

avatar image GerryM · Apr 27, 2012 at 05:47 PM 0
Share

Not sure about the database, but in .NET you could get the current time from a NIST time server. I used this in a unity project not long ago. Doesn't work in the web player, though. Let me know if the function would be useful to you.

avatar image ByteSheep · Apr 27, 2012 at 08:01 PM 1
Share

You can also use the date() function in php to get the current date and then save that value in your database.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Leaton · Nov 20, 2017 at 02:20 AM

Here is the answer I use to keep my time accurate across all devices by utilizing the internet/server time : http://leatonm.net/unity3d-internet-time-date-setup-guide-stop-time-cheat/

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

7 People are following this question.

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

Related Questions

Timestamp and Date from Unity? for mobile 2 Answers

Using a calendar in my game 1 Answer

calendar gui for date selection 4 Answers

Formatting Exception when using DateTime for PlayerPrefs 1 Answer

How to make a date/time system with a fast forward feature? 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