datetime to unix

 
is there any way of converting datetime to unix time with property strict?
 

Question makes no sense. A datetime is a Unix timestamp (broker's time zone).

Strict is irrevalent.

 
William Roeder:

Question makes no sense. A datetime is a Unix timestamp (broker's time zone).

Strict is irrevalent.

What i am trying to do is to print a message on chart using Comment function. Example: New year will start in Years, Months, Days, Hours, Minutes, Seconds.

I was trying to get idea from a candle countdown indicator but when it did not help, i looked into MQL4 help files but no luck.

int OnInit()
  {
//---
   datetime date1=D'2021.01.01 00:00:00';
   datetime date2= date1-TimeLocal();
   Comment(date2); // Prints 1970.01.05 02:22:42 where i want it to be like 0.0.3 10:19:05
//---
   return(INIT_SUCCEEDED);
  }
 
  1. Comment function is irrevalent — that is just how you are displaying it.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. Of course, it prints 1970. 2020… - 2020… is almost zero and zero is 1970.1.1 00:00.

  3. Do your own string.

    #define HR2400 86400 // 24*3600
       int      remaining   = int(Time[0] + PeriodSeconds() - servertime);
       int      seconds     = remaining % HR2400;
       int      days        = (remaining - seconds)/HR2400;
       string   display     = (days > 0 ? string(days)+"-" : "")
                            + TimeToString(remaining, TIME_SECONDS);
    

 
William Roeder:
  1. Comment function is irrevalent — that is just how you are displaying it.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. Of course, it prints 1970. 2020… - 2020… is almost zero and zero is 1970.1.1 00:00.

  3. Do your own string.

Since the new year is about to start, i thought to display a countdown on chart.

if i follow your instructions, i will have to stick to bar times but i do not want to go that way.

Another example: Lets say my birthdate is February 29th.

I am trying to set a countdowm to my next birthday. for that when i try to convert datetime to int, it gives me a warning because of property strict.

if i try to add or subtract one date from another, i do not know the proper way of doing it.

removing property strict solves my problem. but i want to know the way of doing it with property strict.

(in short i want my code to read my birthdate from input, find my next birthday and display a countdown to my next birthday in a format yy.mm.dd hh:mm:ss)

i searched for a solution in documentation and over the internet but no luck. so i asked it here.
 
datetime time_1; //latest time
datetime time_2; //earlier time
int seconds_difference=(int)(time_1 - time_2);
 
Keith Watford:

I used long in place of int:

long time = D'2021.01.01 00:00:00';

it did not give any error or warning. Am i going right?