Now.ToUniversalTime : Now « System « VB.Net by API






Now.ToUniversalTime

  

Public Class Tester
    Public Shared Sub Main
        Dim phaseDay As Double
        Dim result As String

        phaseDay = MoonPhase(Now.ToUniversalTime)

        result = "UTC is now: " & _
           Now.ToUniversalTime.ToString("u") & vbNewLine & vbNewLine
        If (phaseDay < 0) Then
            result &= "Approx days until new moon: " & _
               (-phaseDay).ToString("F1")
        Else
            result &= "Approx days since new moon: " & _
               phaseDay.ToString("F1")
        End If
        Console.WriteLine(result)

    End Sub
    Public Shared Function MoonPhase(ByVal dateUtc As Date) As Double
        Dim days As Double = dateUtc.Subtract(#1/1/1600#).TotalDays
        Dim cycles As Double = days * 0.03386319 - 12.5
        Return Math.IEEERemainder(cycles, 1.0) * 29.53059
    End Function

End Class

   
    
  








Related examples in the same category

1.Now.DayOfWeek
2.Now.Ticks
3.Now.ToLongTimeString
4.Now.ToString