• 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 /
  • Help Room /
avatar image
0
Question by Tap1 · Jul 31, 2017 at 03:24 PM · timenotificationdatetimeseconds

Seconds from now to seven o'clock.

I need to know current time UTC and how many seconds there is to 7:00 pm (or 19:00) So I need this because I have to know how many seconds away to send notification. Let's say that current time UTC is 6:30 pm and player open my app and that register that send notification after 1800 seconds.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by djlw78 · Jul 31, 2017 at 04:39 PM

Well, @Tap1 you would get DateTime.(Now, Etc) and increase it. Example 7h (*times) 60m = 420 (*times) 60 (capturing the seconds) 25, 200 Alternatively go to google and type in hours to seconds and a thing will pop up that will help you convert it.

EDIT: TRY THIS CODE. @Tap1
using System;

namespace ConsoleApp1 { class Program { static void Main(string[] args) { TimeSpan TillSeven; DateTime date = new DateTime(2017, 7, 31, 7, 00, 0); TillSeven = DateTime.UtcNow - date; Console.WriteLine(TillSeven.Hours 60 60); //4 hour 60 = 240 Minutes 60 = 14,400 Seconds. Console.ReadKey(); } } }

Comment
Add comment · Show 2 · 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 Tap1 · Jul 31, 2017 at 04:45 PM 0
Share

Yes but let say that I use DateTime.UtcNow command. That will print current time like 4:00 pm and day. How I can calculate how many minutes away that is from 7:00 pm.

avatar image djlw78 Tap1 · Jul 31, 2017 at 05:17 PM 0
Share

Subtraction. UtcNow - DateTime.<7:00P$$anonymous$$> So you would use DateTime date = new DateTime(2014, 7, 2, 7, 47, 0) (example)

then DateTime.UtcNow - date

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

68 People are following this question.

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

Related Questions

Random Number every 5 seconds 2 Answers

[Android] Push notification for an inactive player 1 Answer

Looking For A Better Way To Check If Day Has Passed 1 Answer

When enter the game calculate the time between last exit to current enter. 0 Answers

how to change the animation lengh by script? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges