Countdown in a lens?

  • Checkout Apoc's answer here! 

    https://lensstudio.zendesk.com/hc/en-us/community/posts/360007065286-How-Do-I-Put-A-Timer-Into-A-Lens-

    Let me know if you have any questions :)

    Comment actions Permalink
  • Thank you very much, Travis! This is very helpful and has given me insight on what route I need to take on this. This isn't quite what I need though. I'm trying to create a lens that counts down to from September 21st. I know that is quite a lot. If you know of something that already does this, that would be absolutely amazing. I doubt something like that exist. I'm not good at scripting, and have no clue where to start on making something like this. I will give it a shot though. Thank you again!

    Comment actions Permalink
  • Got it, so you want to basically show number of days, hours and minutes until September 21st?  

    Comment actions Permalink
  • Yes! Exactly!

    Comment actions Permalink
  • Hi, Zachery.

    Did you find how to add a countdown in your lens?

    Thanks

    Comment actions Permalink
  • Unfortunately, I did not.

    Comment actions Permalink
  • Hello Zachery and Takinours, 

    Here is a great video tutorial on how to make a count down timer using Lens Studio that you can find here.

    If you need to get current time of your device you can get it using this line of code:

    var currentDate = new Date();
     
    This line will get the current date and time in string.
     
    Then you can use to get month time ....
     
    currentDate.getMonth(); // This will get the current month and will return string from (0-11)
     
    Then You can parse a month string to get a month name like this helper function:
     
    function monthCal(value)

    {

    switch(value)

    {

    case"0":

    return"January";

    case"1":

    return"February";

    case"2":

    return"March";

    case"3":

    return"April";

    case"4":

    return"May";

    case"5":

    return"June";

    case"6":

    return"July";

    case"7":

    return"August";

    case"8":

    return"September";

    case"9":

    return"October";

    case"10":

    return"November";

    case"11":

    return"December";

    }

    }
     
    To wrap this up I use this code to get the current date as you can see below:
     
    var currentDataOutput = new Date();

    var month=monthCal(currentDataOutput.getMonth().toString());

    var finalDate=month+" "+currentDataOutput.getDate().toString() +", "+currentDataOutput.getFullYear().toString();

     


    print("Current Date is: " +finalDate);

     
    function monthCal(value)

    {

    switch(value)

    {

    case"0":

    return"January";

    case"1":

    return"February";

    case"2":

    return"March";

    case"3":

    return"April";

    case"4":

    return"May";

    case"5":

    return"June";

    case"6":

    return"July";

    case"7":

    return"August";

    case"8":

    return"September";

    case"9":

    return"October";

    case"10":

    return"November";

    case"11":

    return"December";

    }

    }
     
    This is also a great api reference about date that you can find here.
    Hope this will help you to solve your problem
     
    Best,
    Amir
    Comment actions Permalink
  • Thanks Amir!

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!